GithubHelp home page GithubHelp logo

powerpoint-ili9341_t3's Introduction

Code Generator for Converting PowerPoint Slides to .ino

Speed creating graphical screens for your MCU projects by first creating screens in PowerPoint the automaticall generate the .ino . This utility will convert PowerPoint slide graphics to code that can be compiled and uploaded to common MCU's such as Teensy and ESP-32's and for 320 x 240 and 480 x 320 displays. This code generator is written in VBA and embedded in PowerPoint as a macro. The most common PowerPoint objects are supported making this utility great for creating screens for monitoring systems, control systems, reporting systems, and more. See the examples below.

Tested with

  • Tested with Teensy 3.2 and ILI9341_t3 (320 x 240)
  • Tested with ESP32 and Adafruit_ILI9341 (320 x 240)
  • Tested with Teensy 3.2 and ILI9488_t3 (480 x 320)
  • Revision

  • v1.0 Kasprzak 06/06/2020 Initial code
  • v2.0 Kasprzak 04/04/2024 Support for fonts, colors, variables, buttons, local and global definitions, more
  • Known issues

  • Horizontal gradients where w > h not working--bug in display lib?
  • Teensy Arial fonts match the PowerPoint very well, Adafruit FreeSans--not as good.
  • Usage


    Enable macros: File | Options, Trust Center the navigate to Trust Center Settings, Enable “Enable all macros"
    Enable Developer toolbar: RMB on toolbar Select customize the ribbon, enable Developer Toolbar from right selection group
    Put PowerPoint into presentation mode and click the Generate .INO button or select Developer Tab, Macros, select BuildINO and click Run.

    The resulting code is for a display with pixel size of 320 x 240. Do not adjust PowerPoint slide size, the odd size is intended to make PowerPoint font sizes realistic in the INO (a 12 point font in the .ino code will look similar to a 12 point font in PowerPoint). A different PowerPoint utility (coming soon) is available for 480 x 320 size displays.

    Highlights

  • Support for display library ILI9341_t3
  • Support for display library Adafruit_ILI9341
  • Font support for Teensy Arial fonts in many sizes
  • Font mapping for Arial to basic Adafruit fonts in 4 sizes
  • Option to create Adafruit or custom library buttons from Rectangles with text
  • Option to create button processing code for Touchscreens
  • Option to include XPT2046 touchscreen driver
  • Default orientation is Landscape, but Presentation can be change to portrait mode--a user setting will allow switching screen orientation
  • Option to create variables from numbers in text boxes
  • Option to create button and variables global or in screen functions
  • Font list created and listed in #defines
  • Color list created and listed in #defines
  • Optional variables created for int and float
  • ILI9341_t1 (Teensy) will specify fonts based on PowerPoint fonts
  • Adafruit_ILI9341 (ESP32) can specify either fonts based on PowerPoint fonts or map to closes size delivered with the Adafruit GFX library
  • In either driver case, if PowerPoint fonts do not match delivered display fonts, simply #include the font and change the #defines
  • Option to draw place-holder graphics (square with x) for unsupported PowerPoint Objects
  • char button text created if buttons are created
  • Code generated to create Button objects and initialization

  • User Interface


    header image header image

    Supported objects

    To give examples of what objects and parameters are supported, here are examples of generated code (images on the left), and the origianl slide created in PowerPoint (images on the right). These images will help indicated what is supported and tips on usage. You may delete all slides and create your own, but DO NOT delete slide number 1. Keep this first slide for instructions and the "create" button also the code is hard coded to start at slide number 2. The code generator will do the best job possible in creating .ino graphics to mimic PowerPoint objects, however some parameters for PowerPoint objects are simply not exposed through the API, margins and radius values for rectangles for example. Below are some tips in how to get the most accurate rendition. All screens were first created in PowerPoint the converted to .ino code using this utility. Zero code edits were made to the results.

    header image header image
    header image header image
    header image header image
    header image header image
    header image header image
    header image header image
    header image header image
    header image header image
    header image header image

    Example screen shots

    Here are examples of generated code (images on the left), and the origianl slide created in PowerPoint (images on the right) of some use cases. Create monitoring screens, warning screens, graphical view of an irrigation system, reporting systems, and more...All screens were first created in PowerPoint the converted to .ino code using this utility. Zero code edits were made to the results.

    header image header image

    header image header image
    header image header image
    header image header image
    header image header image
    header image header image
    header image header image


    powerpoint-ili9341_t3's People

    Contributors

    kriskasprzak avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar  avatar  avatar

    powerpoint-ili9341_t3's Issues

    Other displays

    Hi Chris,
    thank you for your wonderful PPT. It is a little late... but... you PPT is great.
    I made a few modification to the makro. You can now set the dimensions (diagonale inch / width + height in pixels) and it calculates the rest and sets the page size automatically.
    This allows it to use it with other displays which support the same commands.
    I'm currently adding the missing parts to a ESP32 / RPI2040 library. Your PPT is very useful!

    Here is the new code - d'dnt want to upload a new PPT here, as it still says "ILI9341" - (could you make a variant with a more generic name (i.e. "tft" instead("ILI9341) and without instruction how to connect etc..???)

    
    Dim txt, ty1 As Integer
    Dim displayWidth
    Dim displayHeight
    Dim SF As Double
    
    Public Sub Create_ILI9341_t3()
        
        ' Edit these values:
        
        displayDiagonalInch = 3.5 'inch
        displayWidth = 480  'pixel
        displayHeight = 320 'pixel
        
        ' ----------------------------------
        
        Dim sw As Double
        Dim diagPix As Double
        Dim objApp As Object
        Dim objSheet As Object
        Dim fs As Object
        Dim TheFile As Object
        Dim Color1 As Long
        Dim Color2 As Long
        Dim Text As String
        Dim Shp As Shape
        Dim Sld As Slide
        Dim objSlide As Object
        Dim x1, y1, x2, y2, x3, y3, r1, tx1, ty1 As Integer
        Dim Top, Left, Width, Height, LineWidth, Radius As Integer
        Dim Path, FileName As String
        Dim i, j, hh, ll, s As Integer
        Dim ButtonText() As String
        Dim Buttonsheet() As Integer
        
        Set objApp = GetObject(, "powerpoint.application")
        Set objPres = objApp.ActivePresentation
        Set fs = CreateObject("Scripting.FileSystemObject")
          
        diagPix = Sqr(displayWidth * displayWidth + displayHeight * displayHeight)
        sw = displayWidth / diagPix * displayDiagonalInch * 72
        SF = (displayWidth - 1) / sw
        objPres.PageSetup.SlideWidth = sw
        objPres.PageSetup.SlideHeight = displayHeight / diagPix * displayDiagonalInch * 72
        
          
        FileName = "ILI9341_Screens"
        Path = objPres.Path
        If Right(Path, 1) <> "\" Then
            Path = Path & "\" & FileName & ".ino"
        Else
            Path = Path & FileName
        End If
        
        Set TheFile = fs.CreateTextFile(Path, True)
        
        
        ' write header  block
        
        TheFile.WriteLine ("/*")
        TheFile.WriteLine ("This code was automatically generated from graphic elements in a PowerPoint presentation")
        TheFile.WriteLine ("and for a Teensy MCU, and a display with ILI9341 driver")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("Autogenerate code written by Kris Kasprzak [email protected]")
        TheFile.WriteLine ("Use this code without warranty")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("Rev  Date         Author     Desc")
        TheFile.WriteLine ("1.0  06/06/2020   Kasprzak   Initial code")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("Connections:")
        TheFile.WriteLine ("Teensy   Display")
        TheFile.WriteLine ("3v3      Vcc")
        TheFile.WriteLine ("GND      GND")
        TheFile.WriteLine ("7        LED (can be 3v3)")
        TheFile.WriteLine ("8        RST (can be 3v3)")
        TheFile.WriteLine ("9        DC")
        TheFile.WriteLine ("10       CS")
        TheFile.WriteLine ("11       MOSI")
        TheFile.WriteLine ("12       MISO")
        TheFile.WriteLine ("11       SCK")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("Notes")
        TheFile.WriteLine ("1. To use SD card replace Resistors 1,2,3 with 0 ohm")
        TheFile.WriteLine ("2. Solder J1 closed")
        TheFile.WriteLine ("*/")
        
        ' write includes
        TheFile.WriteLine ("")
        TheFile.WriteLine ("// You will need to include the appropriate .h files for the fonts")
        TheFile.WriteLine ("// This example useds a combination of the stardard fonts that comes with the ILI9341_t3 and")
        TheFile.WriteLine ("// the custom fonts that come with ILI9341_Fonts library.")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("#include <SPI.h>")
        TheFile.WriteLine ("#include <ILI9341_t3.h>")
        TheFile.WriteLine ("#include <font_ArialBold.h>")
        TheFile.WriteLine ("#include <font_ArialItalic.h>")
        TheFile.WriteLine ("#include <font_ArialBoldItalic.h>")
        TheFile.WriteLine ("#include <font_Arial.h>")
        TheFile.WriteLine ("")
        
        ' write #defines
        TheFile.WriteLine ("#define PIN_LCD 7")
        TheFile.WriteLine ("#define PIN_RST 8")
        TheFile.WriteLine ("#define PIN_DC 9")
        TheFile.WriteLine ("#define PIN_CS 10")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("")
        
        ' create display and DS objects
        TheFile.WriteLine ("ILI9341_t3 Display = ILI9341_t3(PIN_CS, PIN_DC, PIN_RST);")
        TheFile.WriteLine ("")
        
        ' if there are any rounded rectangles, consider those buttons
        ' create the objects
        Text = "// Rounded rectangles will be turned into Adafruit buttons"
        TheFile.WriteLine (Text)
        Text = "// add code for touch screen processing"
        TheFile.WriteLine (Text)
        TheFile.WriteLine ("")
        
        i = 1
        BtnCount = 0
        HasButtons = False
        For s = 2 To objPres.Slides.Count
            Set Sld = objPres.Slides(s)
                For Each Shp In Sld.Shapes
                    If Shp.Type = msoAutoShape Then
                        If Shp.AutoShapeType = msoShapeRoundedRectangle Then
                            ' create a button
                            HasButtons = True
                            BtnCount = BtnCount + 1
                            Text = "Adafruit_GFX_Button Button" & BtnCount & ";"
                            TheFile.WriteLine (Text)
                            
                            ReDim Preserve ButtonText(BtnCount) As String
                            ReDim Preserve Buttonsheet(BtnCount) As Integer
                            
                            Left = Round(Shp.Left * SF)
                            Top = Round(Shp.Top * SF)
                            Width = Round(Shp.Width * SF)
                            Height = Round(Shp.Height * SF)
                            
                            ColorBorder = 65536
                            
                            ' adafruit libs centers the buttons
                            Left = Round(Left + (Width / 2))
                            Top = Round(Top + (Height / 2))
                            
                            ColorText = Color24to16(Shp.TextFrame.TextRange.Font.Color)
                            
                            ColorBTN = Color24to16(Shp.Fill.ForeColor.RGB)
                            If Shp.Line.Visible = msoTrue Then
                                ColorBorder = Color24to16(Shp.Line.ForeColor.RGB)
                            End If
                            BtnText = Shp.TextEffect.Text
                            Text = "Button" & BtnCount & ".initButton(&Display," & Left & ", " & Top & ", " & Width & ", " & Height _
                            & "," & ColorBorder & ", " & ColorBTN & ", " & ColorText & ", """ & BtnText & """, 2);"
                            
                            ButtonText(BtnCount) = Text
                            Buttonsheet(BtnCount) = s
                            
                            
                        End If
                    End If
                Next
        Next
        
        TheFile.WriteLine ("")
        
        
        TheFile.WriteLine ("")
        
        ' write setup
        TheFile.WriteLine ("void setup(){")
        
        TheFile.WriteLine ("")
        TheFile.WriteLine ("pinMode(PIN_LCD, OUTPUT);")
        TheFile.WriteLine ("")
        ' fire up the display
        TheFile.WriteLine ("Display.begin();")
        TheFile.WriteLine ("delay(100);")
        TheFile.WriteLine ("")
        TheFile.WriteLine ("digitalWrite(PIN_LCD, HIGH);")
        TheFile.WriteLine ("")
        
        ' get orientation
        h = objApp.ActivePresentation.SlideMaster.Height
        w = objApp.ActivePresentation.SlideMaster.Width
        If h > w Then
            TheFile.WriteLine ("// use 0 or 2 for portriat mode")
            TheFile.WriteLine ("// you will have to experiment as displays are different")
            TheFile.WriteLine ("Display.setRotation(2);")
        Else
            TheFile.WriteLine ("// use 1 or 3 for landscape mode")
            TheFile.WriteLine ("// you will have to experiment as displays are different")
            TheFile.WriteLine ("Display.setRotation(3);")
        End If
        
        TheFile.WriteLine ("")
        
        If HasButtons = True Then
            For i = 1 To BtnCount
                TheFile.WriteLine (ButtonText(i))
            Next
        End If
        
        TheFile.WriteLine ("")
        TheFile.WriteLine ("}")
        TheFile.WriteLine ("")
        
           
        
        
        ' write loop
        TheFile.WriteLine ("void loop(){")
        TheFile.WriteLine ("")
        s = 0
        For s = 2 To objPres.Slides.Count
    
            TheFile.WriteLine ("")
            Text = "// function call for Screen" & s - 1
            TheFile.WriteLine (Text)
            Text = "Screen" & s - 1
            TheFile.WriteLine (Text & "();")
            If objPres.Slides.Count = 2 Then
                TheFile.WriteLine ("while(1){}")
            Else
    
                TheFile.WriteLine ("delay(5000);")
            End If
            TheFile.WriteLine ("")
            
        Next
        
        TheFile.WriteLine ("}")
        
        
          
        For s = 2 To objPres.Slides.Count
        
            Set Sld = objPres.Slides(s)
    
            TheFile.WriteLine ("")
            Text = "void Screen" & s - 1
            TheFile.WriteLine (Text & "(){")
                    
           
            TheFile.WriteLine ("")
            Set objSlide = Sld
            
            TheFile.WriteLine ("")
            
            ' set back color
            If objSlide.Background.Fill.Type = msoFillGradient Then
            TheFile.WriteLine ("// note displays handle rotations differently so you may have to swap fillScreenVGradient for fillScreenHGradient")
                If objSlide.Background.Fill.GradientStyle = msoGradientHorizontal Then
                    Color1 = Color24to16(objSlide.Background.Fill.GradientStops(1).Color.RGB)
                    Color2 = Color24to16(objSlide.Background.Fill.GradientStops(2).Color.RGB)
                    Text = "Display.fillScreenVGradient(" & Color1 & ", " & Color2 & ");"
                    TheFile.WriteLine (Text)
                ElseIf objSlide.Background.Fill.GradientStyle = msoGradientVertical Then
                    Color1 = Color24to16(objSlide.Background.Fill.GradientStops(1).Color.RGB)
                    Color2 = Color24to16(objSlide.Background.Fill.GradientStops(2).Color.RGB)
                    Text = "Display.fillScreenHGradient(" & Color1 & ", " & Color2 & ");"
                    TheFile.WriteLine (Text)
                End If
            Else
                    Color1 = Color24to16(objSlide.Background.Fill.ForeColor.RGB)
                    Text = "Display.fillScreen(" & Color1 & ");"
                    TheFile.WriteLine (Text)
            End If
            
    
            
            TheFile.WriteLine ("")
                    
            For Each Shp In objSlide.Shapes
               
                ' get lines
                If Shp.Type = msoLine Then
                    ' special case a thick line
                    LineWeight = 0
                    LineWidth = Shp.Line.Weight
                    If LineWidth < 1 Then
                        LineWidth = 1
                    End If
                    If LineWidth > 1 And Shp.Height = 0 Then
                        ' draw a filled rectangle
                        Color1 = Color24to16(Shp.Line.ForeColor.RGB)
                        Left = Round(Shp.Left * SF)
                        Top = Round(Shp.Top * SF)
                        Width = Round(Shp.Width * SF)
                        Height = Round(Shp.Line.Weight * SF)
    
                        Text = "Display.fillRect(" & Left & ", " & Top & ", " & Width & ", " & Height & ", " & Color1 & ");"
                        TheFile.WriteLine (Text)
                    ElseIf LineWidth > 1 And Shp.Width = 0 Then
                    ' draw a filled rectangle
                        Color1 = Color24to16(Shp.Line.ForeColor.RGB)
                  
                        Left = Round(Shp.Left * SF)
                        Top = Round(Shp.Top * SF)
                        Width = Round(Shp.Line.Weight * SF)
                        Height = Round(Shp.Height * SF)
                        
                        Text = "Display.fillRect(" & Left & ", " & Top & ", " & Width & ", " & Height & ", " & Color1 & ");"
                        TheFile.WriteLine (Text)
                    Else
                
                        Color1 = Color24to16(Shp.Line.ForeColor.RGB)
                        Left = Round(Shp.Left * SF)
                        Top = Round(Shp.Top * SF)
                        Width = Round(Shp.Width * SF)
                        Height = Round(Shp.Height * SF)
                        
                        Text = "Display.drawLine(" & Left & ", " & Top & ", " & Width & ", " & Height & ", " & Color1 & ");"
                        TheFile.WriteLine (Text)
                    End If
                End If
                
                If Shp.Type = msoAutoShape Then
                
                        LineWeight = 0
                        If Shp.Line.Visible = msoTrue Then
                           LineWeight = Round(Shp.Line.Weight * SF)
                           If LineWeight < 1 Then
                              LineWeight = 1
                           End If
                        End If
    
                
                    ' test for rectangle
                    If Shp.AutoShapeType = msoShapeRectangle Then
                        Color1 = Color24to16(Shp.Fill.ForeColor.RGB)
                        Left = Round(Shp.Left * SF)
                        Top = Round(Shp.Top * SF)
                        Width = Round(Shp.Width * SF)
                        Height = Round(Shp.Height * SF)
    
                        Text = "// " & Shp.Name
                        TheFile.WriteLine (Text)
                        ' need to test and code for filled rect and gradient fill
                        If Shp.Fill.Type = msoFillSolid Then
                            If LineWeight > 0 Then
                                ' it has a border
                                Color2 = Color24to16(Shp.Line.ForeColor.RGB)
                                ' make a rectangl the color of the border, then later paint an inner rect offset by the linewidth
                                Text = "Display.fillRect(" & Left & ", " & Top & ", " & Width & ", " & Height & ", " & Color1 & ");"
                                TheFile.WriteLine (Text)
                            End If
                            
                            Text = "Display.fillRect(" & Left + LineWeight & ", " & Top + LineWeight & ", " & Width - (2 * LineWeight) & ", " & Height - (2 * LineWeight) & ", " & Color1 & ");  // w=" & Shp.Width
                            TheFile.WriteLine (Text)
            
            
                        ElseIf Shp.Fill.Type = msoFillGradient Then
    
                            If LineWeight > 0 Then
                                ' it has a border
                                Color1 = Color24to16(Shp.Line.ForeColor.RGB)
                                Text = "Display.fillRect(" & Left & ", " & Top & ", " & Width & ", " & Height & ", " & Color1 & ");"
                                TheFile.WriteLine (Text)
                            End If
                            TheFile.WriteLine ("// note displays handle rotations differently so you may have to swap fillRectHGradient for fillRectVGradient")
                            If Shp.Fill.GradientStyle = msoGradientHorizontal Then
                                    Color1 = Color24to16(Shp.Fill.GradientStops(1).Color.RGB)
                                    Color2 = Color24to16(Shp.Fill.GradientStops(2).Color.RGB)
                                    Text = "Display.fillRectVGradient(" & Left + LineWeight & ", " & Top + LineWeight & ", " & Width - (2 * LineWeight) & ", " & Height - (2 * LineWeight) & ", " & Color1 & ", " & Color2 & ");"
                                    TheFile.WriteLine (Text)
                            Else
                                    Color1 = Color24to16(Shp.Fill.GradientStops(1).Color.RGB)
                                    Color2 = Color24to16(Shp.Fill.GradientStops(2).Color.RGB)
                                    Text = "Display.fillRectHGradient(" & Left + LineWeight & ", " & Top + LineWeight & ", " & Width - (2 * LineWeight) & ", " & Height - (2 * LineWeight) & ", " & Color1 & ", " & Color2 & ");"
                                    TheFile.WriteLine (Text)
                            End If
            
                            
                        Else
                            Text = "Display.drawRect(" & Left & ", " & y1 & ", " & x2 & ", " & y2 & ", " & Color1 & ");"
                            TheFile.WriteLine (Text)
                        End If
                        
                        ' does it have text?
                        If Len(Shp.TextFrame2.TextRange.Text) > 0 Then
                            
                            DrawText Shp, TheFile
                        
                        End If
    
                
                    ' test for circle
                    ElseIf Shp.AutoShapeType = msoShapeOval Then
                    
                        ' if user got it close lets make it a circle
                        Color1 = Color24to16(Shp.Fill.ForeColor.RGB)
                        Left = Round((Shp.Left * SF) + (Shp.Width * SF) / 2)
                        Top = Round((Shp.Top * SF) + (Shp.Width * SF) / 2)
                        Radius = Round((Shp.Width * SF) / 2)
    
                        Text = "// " & Shp.Name
                        TheFile.WriteLine (Text)
                        ' need to test and code for filled rect and gradient fill
                        If Shp.Fill.Type = msoFillSolid Then
    
                            If LineWeight > 0 Then
                                ' it has a border
                                Color2 = Color24to16(Shp.Line.ForeColor.RGB)
                                Text = "Display.fillCircle(" & Left & ", " & Top & ", " & Radius & ", " & Color2 & ");"
                                TheFile.WriteLine (Text)
                            End If
                            
                            
                            Text = "Display.fillCircle(" & Left & ", " & Top & ", " & Radius - LineWidth & ", " & Color1 & ");"
                            TheFile.WriteLine (Text)
                            
                
                        Else
                            Text = "Display.fillCircle(" & Left & ", " & Top & ", " & Radius & ", " & Color2 & ");"
                            TheFile.WriteLine (Text)
                        End If
                        
                        ' does it have text?
                        If Len(Shp.TextFrame2.TextRange.Text) > 0 Then
                            
                            DrawText Shp, TheFile
    
                        
                        End If
                    
                
                    ' get triangles
                    ElseIf Shp.AutoShapeType = msoShapeIsoscelesTriangle Then
                        ' if user got it close lets make it a circle
                        Color1 = Color24to16(Shp.Fill.ForeColor.RGB)
                                
                        x1 = Round(Shp.Left * SF)
                        y1 = Round((Shp.Top + Shp.Height) * SF)
                        x2 = Round((Shp.Width + Shp.Left) * SF)
                        y2 = Round((Shp.Top + Shp.Height) * SF)
                        x3 = Round((Shp.Left * SF) + (Shp.Width * SF) / 2)
                        y3 = Round(Shp.Top * SF)
                        Text = "// " & Shp.Name
                        TheFile.WriteLine (Text)
                        ' need to test and code for filled rect and gradient fill
                        If Shp.Fill.Type = msoFillSolid Then
                            Text = "Display.fillTriangle(" & x1 & ", " & y1 & ", " & x2 & ", " & y2 & ", " & x3 & ", " & y3 & ", " & Color1 & ");"
                            TheFile.WriteLine (Text)
                            If LineWeight > 0 Then
                                ' it has a border
                                Color1 = Color24to16(Shp.Line.ForeColor.RGB)
                                Text = "Display.drawTriangle(" & x1 & ", " & y1 & ", " & x2 & ", " & y2 & ", " & x3 & ", " & y3 & ", " & Color1 & ");"
                                TheFile.WriteLine (Text)
                            End If
                        Else
                            Text = "Display.drawTriangle(" & x1 & ", " & y1 & ", " & x2 & ", " & y2 & ", " & x3 & ", " & y3 & ", " & Color1 & ");"
                            TheFile.WriteLine (Text)
                        End If
                        
                        ' does it have text?
                        If Len(Shp.TextFrame2.TextRange.Text) > 0 Then
                            
                            DrawText Shp, TheFile
    
                        
                        End If
                        
                    End If
                
    
                 ' test for text box
                ElseIf Shp.Type = msoTextBox Then
                
                    LineWeight = 0
                        If Shp.Line.Visible = msoTrue Then
                           LineWeight = Round(Shp.Line.Weight * SF)
                           If LineWeight < 1 Then
                              LineWeight = 1
                           End If
                        End If
                        
                        
                    Left = Round(Shp.Left * SF)
                    Top = Round(Shp.Top * SF)
                    Width = Round(Shp.Width * SF)
                    Height = Round(Shp.Height * SF)
                    Text = "// " & Shp.Name
                    TheFile.WriteLine (Text)
                        
                    ' paint a border if it has one
                    If LineWeight > 0 Then
                        ' it has a border
                        Color1 = Color24to16(Shp.Line.ForeColor.RGB)
                        Text = "Display.drawRect(" & Left & ", " & Top & ", " & Width & ", " & Height & ", " & Color1 & ");"
                        TheFile.WriteLine (Text)
                    End If
                    
                    ' first is it filled?
                 
                    If Shp.Fill.Visible = msoTrue Then
                    
                        Color1 = Color24to16(Shp.Fill.ForeColor.RGB)
                        ' need to test and code for filled rect and gradient fill
                        If Shp.Fill.Type = msoFillSolid Then
                            Text = "Display.fillRect(" & Left + LineWeight & ", " & Top + LineWeight & ", " & Width - (2 * LineWeight) & ", " & Height - (2 * LineWeight) & ", " & Color1 & ");"
                            TheFile.WriteLine (Text)
                        End If
            
                        ElseIf Shp.Fill.Type = msoFillGradient Then
    
                            TheFile.WriteLine ("// note displays handle rotations differently so you may have to swap fillRectHGradient for fillRectVGradient")
                            If Shp.Fill.GradientStyle = msoGradientHorizontal Then
                                    Color1 = Color24to16(Shp.Fill.GradientStops(1).Color.RGB)
                                    Color2 = Color24to16(Shp.Fill.GradientStops(2).Color.RGB)
                                    Text = "Display.fillRectHGradient(" & Left + LineWeight & ", " & Top + LineWeight & ", " & Width - (2 * LineWeight) & ", " & Height - (2 * LineWeight) & ", " & Color1 & ", " & Color2 & ");"
                                    TheFile.WriteLine (Text)
                            End If
                            If Shp.Fill.GradientStyle = msoGradientVertical Then
                                    Color1 = Color24to16(Shp.Fill.GradientStops(1).Color.RGB)
                                    Color2 = Color24to16(Shp.Fill.GradientStops(2).Color.RGB)
                                    Text = "Display.fillRectVGradient(" & Left + LineWeight & ", " & Top + LineWeight & ", " & Width - (2 * LineWeight) & ", " & Height - (2 * LineWeight) & ", " & Color1 & ", " & Color2 & ");"
                                    TheFile.WriteLine (Text)
                            End If
    
                    End If
                      
                    ' now we can draw text
                    DrawText Shp, TheFile
    
                    
                ElseIf Shp.Type = msoTable Then
                
                
                    Color1 = Color24to16(Shp.Table.Rows(1).Cells(1).Borders(ppBorderTop).ForeColor) ' border color
                    Color2 = 0 ' text color
                    Color3 = Color24to16(Shp.Fill.BackColor.RGB) 'fill color
                    Color4 = 0 ' cell color
                    
                    Left = Round(Shp.Left * SF)
                    Top = Round(Shp.Top * SF)
                    Width = Round(Shp.Width * SF)
                    Height = Round(Shp.Height * SF)
                    
                    Text = "// " & Shp.Name
                    TheFile.WriteLine (Text)
                    
                    ' draw rows in grid
                    hh = 0
                    For i = 1 To Shp.Table.Rows.Count
                        ' hh = Round(hh + Shp.Table.Rows(i).Height)
                        Text = "Display.drawFastHLine(" & Left & ", " & hh + Top & ", " & Width & ", " & Color1 & ");"
                        TheFile.WriteLine (Text)
                        ll = 0
                        For j = 1 To Shp.Table.Columns.Count
                            
                            ww = Round(Shp.Table.Columns(j).Width * SF)
                            
                            If Shp.Table.Rows(i).Cells(j).Shape.Fill.Visible = msoTrue Then
                                Color4 = Color24to16(Shp.Table.Rows(i).Cells(j).Shape.Fill.ForeColor.RGB)
                                Text = "Display.fillRect(" & Left + ll & ", " & hh + Top & ", " & Round(Shp.Table.Rows(i).Cells(j).Shape.Width * SF) & ", " & Round(Shp.Table.Rows(i).Cells(j).Shape.Height * SF) & ", " & Color4 & ");"
                                TheFile.WriteLine (Text)
                            End If
                          
                            
                            ' is there text in the cell?
                            If Len(Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Text) > 0 Then
                            
                                ' we have a sub below to draw text but too many object differenes
                                ' i could pass some args...maybe later
                                tx1 = Round((Shp.Left + Shp.Table.Rows(i).Cells(j).Shape.TextFrame.MarginLeft) * SF)
                                ty1 = Round((Shp.Top + Shp.Table.Rows(i).Cells(j).Shape.TextFrame.MarginTop + 3) * SF)
                                
                                Color2 = Color24to16(Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Font.Color.RGB)
                                
                                Text = "// you may want to specify the background color"
                                TheFile.WriteLine (Text)
                                
                                Text = "// Display.setTextColor(ForeColor, BackColor);"
                                TheFile.WriteLine (Text)
                                
                                Text = "Display.setTextColor(" & Color2 & ");"
                                TheFile.WriteLine (Text)
                                
                                Text = "Display.setFont("
                                Text = Text & Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Font.Name
                                Text = Text & "_"
                                Text = Text & Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Font.Size
                                
                                If Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Font.Bold = msoTrue Then
                                    Text = Text & "_Bold"
                                End If
                                If Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Font.Italic = msoTrue Then
                                    Text = Text & "_Italic"
                                End If
                                Text = Text & ");"
                                TheFile.WriteLine (Text)
                                Text = "Display.setCursor(" & tx1 + ll & ", " & hh + ty1 + 1 & " );"
                                TheFile.WriteLine (Text)
                                Text = "Display.print(F(""" & Shp.Table.Rows(i).Cells(j).Shape.TextFrame.TextRange.Text & """));"
                                TheFile.WriteLine (Text)
                                TheFile.WriteLine ("")
                            
                            End If
                            
                            ll = Round(ll + (Shp.Table.Columns(j).Width) * SF)
                            
                           
                            
                        Next
                         hh = Round(hh + (Shp.Table.Rows(i).Height * SF))
                    Next
                    ' draw last line
                    Text = "Display.drawFastHLine(" & Left & ", " & hh + Top & ", " & Width & ", " & Color1 & ");"
                    TheFile.WriteLine (Text)
                    Text = "Display.drawFastHLine(" & Left & ", " & Top & ", " & Width & ", " & Color1 & ");"
                    TheFile.WriteLine (Text)
                        
                    
                    ' draw cols in grid
                    ll = 0
                    Text = "Display.drawFastVLine(" & ll + Left & ", " & Top & ", " & Height & ", " & Color1 & ");"
                    TheFile.WriteLine (Text)
                    
                    For i = 1 To Shp.Table.Columns.Count
                        ll = Round(ll + (Shp.Table.Columns(i).Width * SF))
                        Text = "Display.drawFastVLine(" & ll + Left & ", " & Top & ", " & Height & ", " & Color1 & ");"
                        TheFile.WriteLine (Text)
                    Next
                    
    
    
                    TheFile.WriteLine ("")
    
                    
                End If
            
            
            Next Shp
        
        
            TheFile.WriteLine ("")
            
            ' draw any button
            For sss = 1 To BtnCount
                If Buttonsheet(sss) = s Then
                    Text = "Button" & sss & ".drawButton();"
                    TheFile.WriteLine (Text)
                End If
            Next
             TheFile.WriteLine ("")
            
        
            TheFile.WriteLine ("}")
        
        Next
        
        
        ' write closing block
        
        
        TheFile.WriteLine ("/*")
        TheFile.WriteLine ("End of the auto-generated code for ILI9341_t3 screens")
        TheFile.WriteLine ("*/")
        
            
        TheFile.Close
        Beep
        MsgBox "The ILI9341 code is now generated from the PowerPoint presentation.", vbApplicationModal + vbInformation, "PowerPoint to ILI9431_t3 Screen Converter"
        
    
    End Sub
    
    Function Color24to16(ByVal c As Long) As Long
    
        ' Converts RGB 24 bits to 16-bit color required by the ILI9341 driver
        ' i sure miss bit shifting in C
        
        
        Dim r, g, b As Byte
        Dim r5, g6, b5 As String
        Dim temp As String
        
        r = c Mod 256
        g = c \ 256 Mod 256
        b = c \ 65536 Mod 256
        
        If r = 0 Then
            r5 = "00000"
        Else
            r5 = CBin(r)
            r5 = Format((Left(r5, 5)), "00000")
        End If
        
        If g = 0 Then
            g6 = "000000"
        Else
           g6 = CBin(g)
           g6 = Format((Left(g6, 6)), "000000")
        End If
        
        If b = 0 Then
            b5 = "00000"
        Else
            b5 = CBin(b)
            b5 = Format((Left(b5, 5)), "00000")
        End If
        
        temp = r5 & g6 & b5
        
        Color565 = Bin2Dec(temp)
        
        Color24to16 = Color565
            
            
    End Function
    
    Function CBin(ByVal n As Double) As String
        If n = 0 Then
            CBin = 0
        ElseIf n > 0 Then
            Dim i As Double
            Dim c As Long
            i = 2 ^ CLng(Log(n) / Log(2) + 0.1)
            Do While i >= 1
                c = Fix(n / i)
                CBin = CBin & c
                n = n - i * c
                i = i / 2
            Loop
        End If
        CBin = Format(CBin, "00000000")
        ' CBin = Right(CBin, 8)
        
    End Function
    
    Function Bin2Dec(sMyBin As String) As Long
        Dim x As Integer
        Dim iLen As Integer
    
        iLen = Len(sMyBin) - 1
        For x = 0 To iLen
            Bin2Dec = Bin2Dec + _
              Mid(sMyBin, iLen - x + 1, 1) * 2 ^ x
        Next
    End Function
    
    Sub DrawText(Shp As Shape, TheFile As Object)
    
                            
        tx1 = Round((Shp.TextFrame2.TextRange.Item(1).BoundLeft + Shp.TextFrame.MarginLeft - Shp.TextFrame.MarginRight) * SF)
        ty1 = Round((Shp.TextFrame2.TextRange.Item(1).BoundTop + Shp.TextFrame.MarginTop - Shp.TextFrame.MarginBottom) * SF)
        
        Color1 = Color24to16(Shp.TextFrame.TextRange.Font.Color)
        
        Text = "// you may want to specify the background color"
        TheFile.WriteLine (Text)
        Text = "// Display.setTextColor(ForeColor, BackColor);"
        TheFile.WriteLine (Text)
        Text = "Display.setTextColor(" & Color1 & ");"
        TheFile.WriteLine (Text)
        Text = "Display.setFont("
        Text = Text & Shp.TextEffect.FontName
        Text = Text & "_"
        Text = Text & Shp.TextEffect.FontSize
        
        If Shp.TextEffect.FontBold = msoTrue Then
            Text = Text & "_Bold"
        End If
        If Shp.TextEffect.FontItalic = msoTrue Then
            Text = Text & "_Italic"
        End If
        
        Text = Text & ");"
        TheFile.WriteLine (Text)
        Text = "Display.setCursor(" & tx1 & ", " & ty1 & ");"
        TheFile.WriteLine (Text)
        Text = "Display.print(F(""" & Shp.TextEffect.Text & """));"
        TheFile.WriteLine (Text)
        TheFile.WriteLine ("")
                        
    
    End Sub
    

    Code?

    Hello Chris,

    I remembered that you once had a tool that converts PowerPoint files. I thought it was in this repo. Can you tell me where I can find it?

    Thank you,
    Frank

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.