Home

MoaTouch User`s Manual

image

Contents

1. wait card to be inserted sdCard Mount Mount the filesystem const char filelName Filel txt const char file2Name File2 txt if sdCard Exists filelName if sdCard Exists file2Name Ensure file 2 exists sdCard Create file2Name console PrintLine Copying Files filel sdCard Open filelName Open file 1 Comfile Technology MoaTouch User s Manual 60 of 124 MoaTouch User s Manual Files file2 sdCard Open file2Name Open file 2 file2 Truncate clear file 2 s contents uint8 t buffer new uint8 t 512 temporary buffer to use while copying must use heap as stack doesn t support DMA EEY while filel IsEndOfFile copy until the end of the file read data from filel aize t layuesikeae tilel Readout ter Sueco out ter 9 write data to file 2 file2 Write buffer bytesRead catch const exception amp ex console ana WMiieioies s console PrintLine ex what delta tiens dealocate temporary buffer sdCard Close file2 close file 2 sdCard Close filel close file 1 sdCard Unmount unmount the filesystem while true run forever return 0 Console window output COSSA Finished Comfile Technology MoaTouch User s Manual 61 of 124 MoaTouch User s Manual FileInfo Class This class is used with the SDCard Class to get information about an individua
2. HUY F rod oy wa i a o gt FAA Say I N OOT ERAS ERA AA ERA OA I 2 00000040000000 ooooooooopoojo Comfile Technology MoaTouch User s Manual 122 of 124 MoaTouch User s Manual 124 Unit mm Comfile Technology MoaTouch User s Manual 123 of 124 MoaTouch User s Manual Attribution gt Portions of the software make use of Anti Grain Geometry Version 2 4 Copyright C 2002 2004 Maxim Shemanarev McSeem http www antigrain com license index html Portions of this software are copyright 2012 The FreeType Project www freetype org All rights reserved Portions of this software make use of libpng 1 2 50 http www libpng org pub png src libpng LICENSE txt Portions of this software make use of zlib 1 2 7 http zlib net zlib license html Portions of the software are copyright 2003 Bitstream Inc Bitstream Vera is a trademark of Bitstream Inc http dejavu fonts org wiki License VV V WV Comfile Technology MoaTouch User s Manual 124 of 124
3. Y Add file to active project In build target s y EA a noe Edit main cpp as in the previous section int main 0 300bs0nN HelloWorld hw while true hw SayHello Delay_ms 500 include HelloWorld include lt MoaTouch h gt pr using namespace MoaTouch Repeat for HelloWorld h and HelloWorld cpp File Edit View Search Project G6B e ed Xx a Build Debug Fortran wxSmith Tools Tools Plugins DoxyBlocks LA A Files gt Projects Symbols Workspace E Mg HelloWorld al B Sources _ HelloWorld cpp main cpp 4 Headers i HelloWorld h Comfile Technology AAA 8 ster MOLA TS C M e gt 2 a tinclude lt cstdio gt tinclude HelloWorld h void HelloWorld SayHello printf Hello World r n MoaTouch User s Manual 22 of 124 Building the Project Right click the HelloWorld project node and select Build Options x includ includ e i Add files recursively Remove files Find file Project tree Add new virtual folder Format this project AStyle Reparse this project Build Rebuild Clean Open Project Folder in File Browser Properties MoaTouch User s Manual In the next window select the HelloWorld node and select the Pre post build steps tab Then enter the command to generate the hex file
4. Delay for a given number of seconds static void DelayMilliseconds float milliseconds MoaTouch Delay_ms float milliseconds Delay for a given number of milliseconds static void DelayMicroseconds float microseconds MoaTouch Delay_us float microseconds Delay for a given number of microseconds float GetElapsedMicroseconds Get the number of elapsed microseconds float GetElapsedMilliseconds Get the number of elapsed milliseconds float GetElapsedSeconds Get the number of elapsed microseconds bool IsRunning const Returns true if the stopwatch is currently running counting void Reset Resets the counter back to zero without not restarting or stopping the counter void Restart Starts the counter after resetting it to O void Start Starts or resumes the counter void Stop Stop or pause the counter Example This example will measure the time it takes to draw a rectangle to the LCD s buffer and display the elapsed time in the console window include lt MoaTouch h gt using namespace MoaTouch Comfile Technology MoaTouch User s Manual 113 of 124 MoaTouch User s Manual O O i lcd SetBacklightBrightness 255 start off with a blank screen lcd EnableFlush led Clear while lcd HasChanges SolidBrush cyan 0x00 OxFF OxFF RE COMO Stroke stroke 1 0f stroke width of 1 0 pixels Stopwatch sw sw Start begin counting draw th
5. 0 0f Creates a new point at x y Point const Point amp source Copy constructor Fields float x This point s x coordinate float y This point s y coordinate Methods static float GetHoirzontalDisplacement const Pointg p0 const Point amp pl Gets the horizontal displacement between p0 and p1 static float GetVerticalDisplacement const Pointg p0 const Point amp pl Gets the vertical displacement between p0 and p1 static float GetDisplacement const Point amp p0 const Point amp pl Gets the displacement between p0 and p1 static float GetAngleRadians const Point amp p0 const Point pl Gets the angle from the horizontal in radians for the line connecting p0 and p1 Operators Point amp operator const Point amp source Copy assignment operator bool operator const Point amp rhs Returns true if this point s coordinates are equal to rhs s coordiantes bool operator const Point amp rhs Returns true if this point s coordinates are not equal to rhs s coordiantes Comfile Technology MoaTouch User s Manual 97 of 124 MoaTouch User s Manual RadialGradientBrush Class This class is used with the various drawing features of the MoaTouch to display shapes in a 2 color radial gradient This class implements the Brush Class Constructors RadialGradientBrush Instantiate a new uninitialized instance of this class RadialGradientBrush const GradientStop amp center fl
6. MoaTouch User s Manual DigitalInputs Class This class simply provides indexers for retrieving the DigitalInputs Class instances Operators DigitalInput amp operator DigitalInput Pin pin const Returns the DigitalInputs Class instance assigned to the given pin DigitalInput amp operator int index const Returns the Digitallnputs Class instance at the given index Will throw a std out_of range exception of index is invalid Comfile Technology MoaTouch User s Manual 52 of 124 MoaTouch User s Manual DigitalOutput Class The MoaTouch has 4 GPIO digital outputs This class provides access to those outputs Instances of this class can be retrieved via the digitalOutputs int index or digitalOutputs DigitalOutput Pin pin indexers DigitalOutput Pin Enum An enumeration for identifying an individual digital input channel 00 03 Methods static DigitalOutput amp GetInstance Pin pin Get the instance of this class for the given pin Pin GetPin const Returns the DigitalOutput Pin assignment for this instance bool IsHigh const Returns true if the input is a logic high bool IsLow const Returns true if the input is a logic low bool IsOn const Returns true if the current output state is logic high bool IsOff const Returns true if the current output state is logic low void On bool on true Sets the current output state to logic high on true or logic low on fa
7. World _Set Date and Time Reset World World World sa r a x Clear Timestamp wor H World Program Upload World n World nn Browse Upload World World World World World World World Hello World Hello l Console Window V Show Always On Top C MoaTouch Hello World Helk COMI15 Open Comfile Technology MoaTouch User s Manual 24 of 124 MoaTouch User s Manual Coordinate System The MoaTouch features an 800 x 480 pixel display The X axis increases from left to right while the Y axis increases from top to bottom The origin 0 0 is the top left corner of the display Origin X Axis 0 0 Y Axis Coordinates are in units of pixels and are always relative to the active layer s origin So if drawn to the background layer the code SolidBrush white OxFF OxFF OxFF Stroke stroke 1 0 LineCap Butt LineJoin Round Fedi Drawibine Om OO Oe 00 Ot ar COOL SELOke Wide e Will draw a diagonal line from the top left corner of the screen to the bottom right corner of the screen However notice that functions for drawing vector graphics employ floating point arguments This means it s possible to specify coordinates of sub pixels e g half of a pixel So that might beg the question How does half of a pixel appear To answer that question consider the code SolidBrush white OxFF OxFF OxFF Stroke stroke 1 0 LineCap Butt LineJoin Round Lal D
8. Bits8 serialPort Openi32 32 run forever while true if data has been received if serialPort GetRxCount gt 0 char buffer 32 read the data received aize y layuesiieacd serialPort iecad lui 32 9 echo the data received serialPort Write buffer bytesRead return 0 Results using Comfile Technology s CFTerm Port comz 115200 Baud vw 7 Clear after sending Rate Close View Type HEX y FT RTS T DTR NoParty y I Test Send TT Repeat Cycle ms fro Delay between bytes fo Send instantly character by character as you ms maximum 500 type letters p TX amp RX TX 61 a 62 b 63 c 64 d 65 e 66 f 67 g 61 a 62 b 63 c 64 d 65 e 66 f 67 g Comfile Technology MoaTouch User s Manual 104 of 124 MoaTouch User s Manual SDCard Class This class provides access to the MoaTouch s micro SC Card It is implemented as a singleton class whose instance can be accessed via the sdCard identifier The MoaTouch does not support C file I O with fopen fread fwrite nor does it support C IO streams Please use this class along with the File and FileInfo Class for all file I O The MoaTouch only supports 8 3 file names 8 character name 3 character extension Due to this standard file names are always displayed in upper case characters even if lower case characters are specified Methods void Close File file void Close Fileg file C
9. GradientStop GetStart const Returns a copy of the start GradientStop void SetStart const GradientStopg value Sets the start GradientStop to the given value MoaTouch GradientStop GetEnd const Returns a copy of the stop GradientStop void SetEnd const GradientStop amp value Sets the stop GradientStop to the given value MoaTouch BrushType GetType const Returns BrushType LinearGradient to identify this brush as a linear gradient brush Operators LinearGradientBrushg operator const LinearGradientBrush amp source Copy assignment operator Example include lt MoaTouch h gt aime O start off with a blank screen lcd SetBacklightBrightness 255 led EnableFlush lcd Clear while lcd HasChanges Create a gray to blue gradient brush Color karay OCO 0x00 0201 Calor piue 0233 000 0299F GradientStop start 400 0f 200 0f gray GradientStop end 400 0f 280 0f blue LinearGradientBrush brush start end Display a rounded rectangle with the brush leck iiirectemg lle S000 200 0 200 0 80 06 20 0 Imusla g Comfile Technology MoaTouch User s Manual 77 of 124 MoaTouch User s Manual run forever while true return 0 Comfile Technology MoaTouch User s Manual 78 of 124 MoaTouch User s Manual LineCap Enumeration This enumeration is used with the Stroke Class to define the appearance of the stroke s end caps Items Butt Li
10. lcd DrawRectangle m_area stroke white int main Configure callbacks for receiving touch events touch SetOnTouch OnTouch touch SetOnMove OnMove touch SetOnRelease OnRelease Configure the serial port serialPorts 1 SetBaudRate 57600 serialPorts 1 Open 32 32 Configure the Modbus RTU Master ModbusRTUMaster modbus serialPorts 1 100 Create an array of 8 LEDs corresponding the ModPort s 8 outputs on the MD DOSI8 const uint8 t NUM_OF LEDS 8 LEDButton leds NUM_OF LEDS LEDButton 0 amp modbus LEDButton 1 amp modbus LEDButton 2 amp modbus LEDButton 3 amp modbus Comfile Technology MoaTouch User s Manual 85 of 124 MoaTouch User s Manual LEDButton 4 amp modbus LEDButton 5 amp modbus LEDButton 6 amp modbus LEDButton 7 amp modbus be Run program forever while true If the operator touched the screen but our program has not yet handled the touch event if handledTouch Give each LED the chance to process the touch event for uint8 t i 0 i lt NUM OF LEDS i a short delay to improve reliability Deles sass 11 5 Give the LED a chance to process the touch event if leds i ProcessTouch touchedPoint If the touch corresponds to this LED no need to check the other LEDs Just exit break Don t process any more touches until the operator s finger is released handledTouch
11. without loosing any definition This makes them particularly useful for rendering dynamic content such as gauge needles and graphs Comfile Technology MoaTouch User s Manual 28 of 124 MoaTouch User s Manual Raster Graphics Raster graphics are simply arrays of plotted pixels They are mostly used for displaying photographs and other file based images The M Display supports two functions for drawing raster graphics LCD DrawImage and LCD SetPixels LCD DrawImage can be used to read a PNG file from the SD Card and plot it to the screen at a given location LCD SetPixels is used to plot one or more pixels at a specified location and can be used to plot images on the screen without needing to read from the SD Card The following example shows an image of a gauge being displayed from a PNG file on the SD Card Clear the background layer led Clearids Read the image from the SD Card File file sdCard Open gauge png Display the image 1cd DrawImage 229 0f 115 0f file Clean up sdCard Close file Comfile Technology MoaTouch User s Manual 29 of 124 MoaTouch User s Manual Fonts and Text The MoaTouch supports the TrueType font format TrueType fonts are actually a specialized class of vector graphics and can therefore be scaled stroked and filled just like vector graphics The shape of the characters a k a glyphs are stored in a TrueType font file The MoaTouch can read these glyphs from
12. 0 pixel thick Stroke strokel 1 0f SolidBrush green 0x00 OxFF 0x00 salia OO OE ae OO OES OOH ee Ohm SOP Oe Eiaolgail Eras y draw a fuchsia elliptical arc 3 0 pixels thick Stroke stroke3 3 0f SolidBrush fuchsia OxFF 0x00 OxFF Tedi DrawAre 000r LO AO O DO MO 0 200 Strokes Etelasila 7 run forever while true return 0 Comfile Technology MoaTouch User s Manual 72 of 124 Example Circles and Ellipses include lt MoaTouch h gt using namespace MoaTouch int main draw a green circle SolidBrush green 0x00 OxFF 0x00 led TEk eke LDO 0 LOLOL 30 0 oreen gt draw a red ellipse SolidBrush Tedi 0xkH 0x00 0x007 Ikeclawaiiinilisiase SO0 0 100 0 S060 Wee iwecl run forever while true return 0 include lt MoaTouch h gt using namespace MoaTouch int main Green with a stroke 1 pixel wide SolidBrush green 0x00 OxFF 0x00 Stroke stroke 1 0f draw a circle led DrawCircle 200 0f 200 0f 100 0f stroke green draw an ellipse led DrawHllipse 300 0 300 0 100 0 75 0 stroke green run forever while true return 0 Comfile Technology MoaTouch User s Manual MoaTouch User s Manual 73 of 124 Example Lines Curves include lt MoaTouch h gt using namespace MoaTouch MoaTouch User s Manual int main JS stas loss Fear Stroke stroke 1 0f Draw whi
13. 3 types of graphics Vector Graphics Raster Graphics and Fonts for text Vector Graphics The majority of the MoaTouch s graphic library repertoire is used to draw vector graphics Vector graphics consist of geographical primitives lines curves rectangles circles etc that can be used in isolation or in combination with other visuals to create buttons graphs charts panels or just about any other visual that can be imagined Vector graphics functions can be broken down into 2 categories stroked visuals and filled visuals Stroked visuals draw an outline around the shape and filled visuals have their interior filled with a specific color or pattern The following draws two rectangles one stroked and one filled Functions that draw stroked shapes begin with Draw and functions that draw filled shapes begin with Fill The MoaTouch also contains a Path class for drawing arbitrary shapes The following example shows two different rectangles one stroked and one filled Clear the background layer 1lcd Clear Draw a stroked rectangle SolidBrush green 0x00 OxFF 0x00 Stroke stroke 1 0 LineCap Butt LineJoin Miter 1cd DrawRectangle 50 0f 50 0f 100 0f 100 0f stroke green Draw a filled rectangle SolidBrush fuchsia OxFF 0x00 OxFF ledi il rece rea le 200 01 50 0 WOO O01 WOOO SEXO Euciisila y Vector graphics can be mathematically transformed rotated scaled translated etc
14. 32 bit unsigned integer void SetGateway uint8 t oct3 uint8 t oct2 uint8 t octl uint8 t oct0 Sets the gateway address using individual octets Socket amp GetSocket Socket Number number Get the instance of the given socket See the Socket Class Example See the Socket Class Example for a demonstration of this class Comfile Technology MoaTouch User s Manual 55 of 124 MoaTouch User s Manual ExDigitalInput Class The MoaTouch has 32 expansion digital inputs This class provides access to those inputs Instances of this class can be retrieved via the exDigitalInputs int index Or exDigitalInputs ExDigitalInput Pin pin indexers ExDigitalInput Pin Enum An enumeration for identifying an individual digital input channel 10 13 Methods Pin GetPin const Returns the DigitalInput Pin assignment for this instance bool IsHigh const Returns true if the input is a logic high bool IsLow const Returns true if the input is a logic low bool IsOff const Returns true if the input is a logic low bool IsOn const Returns true if the input is a logic high Comfile Technology MoaTouch User s Manual 56 of 124 ExDigitalInputs Class This class simply provides indexers for retrieving the ExDigitalInput Class instances Methods std function lt void uint32_t gt GetOnChanged const Gets the function to be called when one of the inputs state changes void SetOnChanged std
15. OPS A A A a 116 EXP iia 116 Systemi ClASS iia AAA A RIA AAA EA OA ADA 117 A lt c 28e0 naa exsasesaun E EE ten sescnamnasaheeamanere tsa nae A E E dace cate ETE TE cap tes 117 A A 118 Me Sinai As ais 118 A TREE 118 TOCA MAS aia 120 MEA a 120 EXAMPLES ccoo TAS RARA A AREA AAA AA ARA A A 120 A et aaginesaeeaateaies soca de sare ieee caanmanaannanageaegeeaaes hss jseancaearsseiadenaedideaaes beneaacaiaame EA 121 AGinIDUEION asias ar di 124 Comfile Technology MoaTouch User s Manual 5 of 124 MoaTouch User s Manual The MoaTouch is a high color C programmable touch controller which combines touch input colorful output RS 232 485 and Ethernet communication and digital amp analog I O ports The MoaTouch library provides convenient access to all IO features and a rich set of user interface features such as vector graphics raster graphics TrueType fonts and PNG images Courtesy of the GNU toolchain users can take advantage of many C 11 features such as lambda functions initializer lists range based for loops and more Features High Color TFT display Touch Input RS 232 and RS 485 communication Non volatile Memory Digital Input and Output Analog Input Real Time Clock TCP IP Ethernet Vector graphics lines rectangles circles curves text images and many other drawing primitives Solid colors and linear radial gradients Alpha blending transparency and partial transparency TrueType font and Unicode Support PNG
16. TCP IP communication The MoaTouch has 4 sockets The MoaTouch does not have a DHCP client but there is no reason one couldn t be built with the MoaTouch s features The MoaTouch does not support UDP Methods void GetHardwareAddress uint8_t value const Gets the hardware address of the MoaTouch as an array of 6 bytes void SetHardwareAddress uint8_t value Sets the hardware address of the MoaTouch as an array of 6 bytes void SetHardwareAddress uint8_t oct5 uint8 t oct4 uint8 t oct3 uint8 t oct2 uint8 t octl uint8 t oct0 Sets the hardware address of the MoaTouch using individual octets uint32 t GetIPAddress const Gets the IP address of the MoaTouch as a 32 bit unsigned integer void SetIPAddress uint32 t value Sets the IP address of the MoaTouch as a 32 bit unsigned integer void SetIPAddress uint8 t oct3 uint8 t oct2 uint8 t octl uint8 t oct0 Sets the IP address of the MoaTouch using individual octets uint32 t GetSubnetMask const Gets the subnet mask of the MoaTouch as a 32 bit unsigned integer void SetSubnetMask uint32 t value Sets the subnet mask of the MoaTouch as a 32 bit unsigned integer void SetSubnetMask uint8 t oct3 uint8 t oct2 uint8 t octl uint8 t oct0 Sets the subnet mask of the MoaTouch using individual octets uint32_t GetGateway const Gets the gateway address as a 32 bit unsigned integer void SetGateway uint32 t value Sets the gateway address as a
17. a std runtime_error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method slaveAddress The Modbus slave address of the device to query startAddress The Modbus address of the first register to write value The collection of sequential values to write Status GetStatus Gets the current operating status of this instance Status WaitForResponse Wait until a response to the current query has been received or an error The status ending the wait is returned void GetResponse std vector lt uint16_t gt s values Gets the response from a register query function codes 3 4 6 16 This method will throw a std runtime error if the status is not Status ResponseReceived It is recommended to verify the status with the GetStatus method before calling this method The result is written to values void GetResponse std vector lt bool gt 8g values Gets the response from a boolean query function codes 1 2 5 15 This method will throw a std runtime error if Comfile Technology MoaTouch User s Manual 83 of 124 MoaTouch User s Manual the status is not Status ResponseReceived It is recommended to verify the status with the GetStatus method before calling this method The result is written to values Example This example illustrates a combination of the UI Touch and Modbus features of the MoaTouch It uses the ModbusRTUM
18. a string to an integer Same as std stoi long ToLong const std string amp s size t pos 0 int base 10 Parses a string to a long integer Same as std stol unsigned long ToULong const std string amp s size t pos 0 int base 10 Parses a string to an unsigned long integer Same as std stoul float MoaTouch ToFloat const std string amp s size t pos Parses a string to a single precision floating point Same as std stof double MoaTouch ToDouble const std string amp s size t pos Parses a string to a double precision floating point Same as std stod std u32string ToUTF32 const std string amp s Converts a UTF 8 string to a UTF 32 string std string ToUTF8 const std u32string amp s Converts a UTF 32 string to a UTF 8 string Comfile Technology MoaTouch User s Manual 115 of 124 MoaTouch User s Manual Stroke Class This class represents the characteristics of the line used to draw the outline of shapes Constructors Stroke float width 2 0f LineCap cap LineCap Butt LineJoin join LineJoin Miter Creates a new stroke with the given width cap and join characteristics Stroke const Stroke amp source Copy constructor Methods float GetWidth const Gets the width of the stroke line width void SetWidth float value Sets the width of the stroke line width LineCap GetCap const Gets the stroke s line cap end cap void SetCap LineCap value Sets the strok
19. an elf executable The linker is invoked with the C compiler in order to automatically link in the toolchain s built in libraries arm none eabi g mthumb mcpu cortex m4 mfpu fpv4 sp d16 mfloat abi softfp W1 gc sections L C Program Files x86 ComfileTools MoaTouch Tools lib W1 whole archive 1MoaTouch W1 no whole archive W1 T C Program Files x86 ComfileTools MoaTouch Tools linker script MoaTouch 1d HelloWorld o main o o HelloWorld elf gt arm none eabi g Invoke the linker throught the GNU C compiler gt mcpu cortex m4 The MoaTouch s MCU is an ARM Cortex M4 gt mthumb The MoaTouch s MCU uses the ARM Thumb 2 instruction set gt mfpu fpv4 sp d16 mfloat abi softfp Use the ARM Cortex M4 s Floating Point Unit FPU gt WI whole archive IMoaTouch WI no whole archive gt W1 gc sections Remove any unused code to reduce the executable s size gt L C Program Files x86 ComfileTools MoaTouch Tools lib W1 whole archive 1MoaTouch W1 no whole archive Link with the MoaTouch static library gt W1 T C Program Files x86 ComfileTools MoaTouch Tools linker scriptiMoaTouch ld Use the MoaTouch linker script This linker script tells the linker the structure of the MoaTouch s memory so it can create a compatible executable gt HelloWorld o main o Add the object files created in the compilation stage This will create a HelloWorld elf file which is the program s exe
20. executing a program and dipswitch 2 is in the OFF position the program will restart Comfile Technology MoaTouch User s Manual 12 of 124 MoaTouch User s Manual Installing MoaTouch Virtual Serial Port Console Driver When dipswitch 2 is in the OFF position the MoaTouch s USB port can function as an output console for debugging and monitoring a program s execution Once again you can find a link to the driver s installation utility in Windows Start Menu under Comfile Tools eN MoaTouch Console Driver ml After installing the driver if you set dipswitch 2 to the OFF position and power on the MoaTouch you will see the MoaTouch appear as STMicroelectronics Virtual COM Port COMxx in Windows Device Manager The COM port number will vary a 17 Ports COM amp LPT 1 STMicroelectronics Virtual COM Port COM15 Now using the MoaTouch Control Panel you can view output from the MoaTouch in the MoaTouch Control Panel s Console Window Please be aware that the MoaTouch will not appear as a virtual serial port until a working program is uploaded to it include lt MoaTouch h gt using namespace MoaTouch int main while true console PrintLine Hello World Delay_ms 500 return 0 SA EAS a Open c E World World World World v Always On Top World 4 World Set Date and Time Reset World Console Window A y ar Y Show Always On Top World Clear Ti
21. is released O std function lt void Point point gt GetOnTouch const Gets the function to call when the user first touches the screen void SetOnRelease std function lt void Point point gt onRelease Sets the function to call when a touch is released point is the last point on the screen that the user touched void SetOnMove std function lt void Point point gt onMove Sets the function to call when the user moves drags while touching point is the point on the screen the user s touch moved to void SetOnTouch std function lt void Point point gt onTouch Sets the function to call when the user first touches the screen point is the point on the screen where the user touched Examples Please see Calibrating the Touch Screen for an example demonstrating how to calibrate the touch screen with the Calibrate method Please see the Buzzer Class Example for a demonstration of responding to the touch move and release events Comfile Technology MoaTouch User s Manual 120 of 124 MoaTouch User s Manual Dimensions SSS SQ O E 5 E En E NNN On a On B 1145 A C 3 3 Comfile Technology MoaTouch User s Manual 121 of 124 MoaTouch User s Manual 185 124 18 65 26 35
22. layer s origin returns the absolute point relative to the screen s origin Point GetRelativePoint const Point amp absolutePoint const Given an absolute point relative to the screen s returns the point relative to this layer s origin Area GetAbsoluteArea const Areas relativeArea const Given an area relative to this layer s origin returns an absolute area relative to the screen s origin Area GetRelativeArea const Areas absoluteArea const Given an absolute area relative to the screen s returns an area relative to this layer s origin Raster Graphics Methods This class implements all of the Layer Class s Raster Graphics Methods Vector Graphics Methods This class implements all of the Layer Class s Vector Graphics Methods Comfile Technology MoaTouch User s Manual 64 of 124 MoaTouch User s Manual Text Methods This class implements all of the Layer Class s Text Methods Comfile Technology MoaTouch User s Manual 65 of 124 MoaTouch User s Manual GradientStop Class This class is by the LinearGradientBrush Class and RadialGradientBrush Class to specify the brush s coordinates and colors Constructors GradientStop Instantiates a new uninitialized instance of this class GradientStop const Point amp point const Color color Instantiates a new instance of this class at the specified point and with the given color Coordinates are relative to the active layer GradientStop const Gr
23. see Raster Graphics for a demonstration of this method void SetPixel const PixelPointg point const Color amp color Set the pixel at the given point to the given color void SetPixels const PixelPoint amp firstPoint const std vector lt Color gt g colors Set a consecutive row of pixels starting at point firstPoint to the given colors Vector Graphics Methods void DrawLine const Point amp p0 const Pointg pl const Strokes stroke const Brushg brush Draw a line from p0 to p1 using the given stroke and brush Please see Example Lines Curves for a demonstration of this method void DrawRectangle const Area amp area const Strokeg stroke const Brush amp brush Draw the perimeter of a rectangle encompassing the given area using the given stroke and brush Please see Example Rectangles for a demonstration of this method void DrawRectangle const Areas area float cornerRadius const Stroke amp stroke const Brushg brush Draw the perimeter of a rounded rectangle encompassing the given area with a uniform cornerRadius using the given stroke and brush Please see Example Rectangles for a demonstration of this method void DrawRectangle const Area amp area float topLeftCornerRadius float topRightCornerRadius float bottomLeftCornerRadius float bottomRightCornerRadius const Stroke amp stroke const Brush amp brush Draw the perimeter of a rounded rectangle encompassing the given area with nonun
24. to those inputs Instances of this class can be retreived via the analogInputs int index or analogInputs AnalogInput Pin pin indexers AnalogInput Pin Enum An enumeration for identifying an individual analog input channel AnalogInput A0 A3 corresponds to channels 0 3 respectively Methods AnalogInput Pin GetPin const Gets the AnalogInput Pin for this instance uintl6 t GetValue Perform an analog to digital conversion and return the resulting value Example This example reads from analog input O and plots its value as a graph include lt MoaTouch h gt using namespace MoaTouch int main lcd SetBacklightBrightness 255 start off with a blank screen lcd EnableFlush led Elesi iie while 1cd HasChanges SolidBrush white 0xFF OxFF OxFF IN eaae aa LEE SolidBrush green 10x00 OxFF 0x00 value in green Stroke linel 1 0 use a stroke width of 1 pixel POE cursor 0 3 the current x coordinate float previousValue 479 0f previous and current y coordinates float currentValue 479 0f while true advance the cursor and wrap around when advancing past the edge of the screen cursor cursor gt 790 56 2 U25f cursor Lt previousValue currentValue scale ADC value to the height of the screen currentValue analogInputs 0 GetValue lcd GetArea GetHeight 4096 0f currentValue 480 0f currentValue because y axis is top to bott
25. turn off If off is false the buzzer will turn on void On bool on true Turns the buzzer on The on argument is optional If on is true the buzzer will turn on If on is false the buzzer will turn off void SetFrequency float value Sets the frequency in hertz of the sound to emit Example This example will turn the buzzer on when the screen is touched It will turn off the buzzer with the the touch is released The frequency emitted is a function of the x coordinate of the touch so touching farther to the right will emit a higher frequency sound and touching farther to the left will emit a lower frequency sound include lt MoaTouch h gt using namespace MoaTouch seati Onc On Lome his oime o buzzer On Turn on the buzzer and set the initial frequency buzzer SetFrequency p x static void OnMove Point p buzzer SetFrequency p x Change the frequency of the buzzer when touch moves static void OnRelease Point p buzzer O Turn off buzzer when touch is released int main Assign functions to handle the touch events touch SetOnTouch OnTouch touch SetOnMove OnMove touch SetOnRelease OnRelease while true run forever return 0 Comfile Technology MoaTouch User s Manual 42 of 124 MoaTouch User s Manual BrushType Enumeration This enumeration is used to distinguish between the different brushes SolidBrush LinearGradientBrush and RadialGradie
26. will write to every location in the non volatile memory and then read back and verify the value include lt MoaTouch gt using namespace MoaTouch A O write values one byte at a time to the non volatile memory console PrintLine Writing Values for size t 1 0 i lt nvrem GetCapacityinBytes 1 uint t value a 256 nvram Write i amp value 1 read and verify the values from the non volatile memory one byte at a time console PrintlLine Reading Values for size t i 0 i lt nvram GetCapacityIinBytes 7 i uint8 t value lao eyoecredWale i 256 read the value from non volatile memory nvram Read i value 1 verify the value if value expectedValue console PrintLine Error d d value expectedValue break run forever console PrintLine Finished while true return 0 Console window output Writing Values Reading Values Comfile Technology MoaTouch User s Manual 87 of 124 MoaTouch User s Manual Finished Comfile Technology MoaTouch User s Manual 88 of 124 MoaTouch User s Manual Path Class This class is used to draw arbitrary shapes Factory methods The following methods are static methods that construct and return a new instance of a path They can be called with the Path FunctionName syntax static Path Line const Pointg p0 const Point amp pl Create a line from point po to poi
27. 0 largeArc 0 sweep 0 sweep 1 Arcstart Arc start largeArc 1 largeArc 1 sweep 0 sweep 1 void Close Close the shape See Example Pie Section for a demonstration Operators Path amp operator const Path amp source Copy assignment operator Example Pie Section include lt MoaTouch h gt using namespace MoaTouch Comfile Technology MoaTouch User s Manual 90 of 124 int main Comfile Technology Create a section of a pie Path path path MoveTo 200 0f 200 0f das iS AOS hep MA A Path ArcTo 100 0 100 0 00 false true 270 7 270 7 path Close Fill the section with dark red SolidBrush darkRed 0x54 0x00 0x00 lced FillPath path darkRed Outline the section in bright red SolidBrush brightRed OxFF 0x00 0x00 Stroke stroke 1 0f lcd DrawPath path stroke brightRed while true return 0 MoaTouch User s Manual MoaTouch User s Manual 91 of 124 MoaTouch User s Manual Example Curve include lt MoaTouch h gt using namespace MoaTouch int main Create a curve Path path pathi Mowe lon He2 OO Ot mee Om Ota a ee aida Chievo OO Gir 00 0 00 0 LOW Wie AO 200 071 Draw the curve SolidBrush cyan 0x00 OxFF OxFF Stroke stroke 5 0 lcd DrawPath path stroke cyan while true return 0 Comfile Technology MoaTouch User s Manual 92 of 124 MoaTouch User s Ma
28. 14 G 1 3 5 7 V 8 10 12 14 G Input Output Port 1 16 18 20 22 G 25 27 29 31 16 18 20 2 G G 25 27 29 31 V S G 17 19 21 23 24 26 28 30 G 17 19 21 23 V 24 26 28 30 G See Electrical Specifications for more information Comfile Technology MoaTouch User s Manual 7 of 124 MoaTouch User s Manual Serial Analog and Digital I O Ports Analog Input Port Optional Digital I O Port Optional Gnd Ground Gnd Ground Pin AO A3 analogInputs 0 3 V Source Voltage See Electrical Specifications for more information Pin I0 I3 digitalInputs 0 3 Pin O0 03 digitalOutputs 0 3 See Electrical Specifications for more information Analog Input Port Digital I O Port A0 A1 A2 A3 Gnd 10 11 12 13 O0 01 02 03 V Gnd Serial Serial Serial Serial Power Input PortO Port 1 Port2 Port 3 Gnd Tx RxGnd Tx Rx Gnd RS 485 RS 232 Serial Ports Serial Port 0 3 serialPorts 0 3 Comfile Technology MoaTouch User s Manual 8 of 124 Electrical Specifications MoaTouch User s Manual Max V 50V Output Current 500mA Digital Output Output Sink ON creates a path to ground Input Voltage 24V Input Current 2mA Input Impedance 12KQ On Level gt 17V VDC 24V Off Level lt 5V Isolation None Digital Input ESE Ea e a A A Max Voltage 5V Input Impedance 440KQ A Isolation Non
29. 67 Vector Graphics Methods A AR 67 Text Methods it A A E is 69 A dave sschixeh weckccanneuaessatnatesesh deen ads aa aE E gece athadd satnameadecacaneaeietaaanaamasaesee 71 Miscellaneous Methods siii A AR il 71 Raster Graphics MENOS cc ot O E a 71 Vector Graphics Methods reena aE A E ana do ceasa EE EEE AE Haden ON Er E EA 71 TEXE MEENOOSS ii aaa 71 Example ARCS 3 iiccssicacscisnscertnaveneocad A AAA A AAA A A AAA 72 Example Circles and EllpSeS comi dba 73 Example Lin S CURVES 0 datar 74 Example Rectangles ir iia 75 Comfile Technology MoaTouch User s Manual 3 of 124 MoaTouch User s Manual EXE Plotting PAS iO 76 LinearGradient Brush Glass ata cr iia 77 CONSUELO St iia taa 77 Me Susi A iaa 77 OPS opos 77 EEDA OY is o 77 Line Cals EINEN A a arcas 79 TO Si ia A a A AA AAA AA A A AR AA 79 SA 79 LINEIOIA Enumeratio sara iia rad da AER 80 MOS rra drid Aia A A A da ia 80 EXAME a E aa EAEE EE AAE E 4d AAA aauslsl awa ode aa EEE EEEE nite SEa EAE 80 M m ryStreamm Clase T a E S O EE O 81 CONSTRUCTOR le 81 Methods artrosis s 81 Example 23 isis NN 81 ModbusRTUMaster ClaSS ac A di 82 ModbusRTUMaster Status EU a dada 82 CONS MUTO PS ici a A a oie 82 Methods union A A iS 82 Sl E E T E E E saoiieneenseieatiahd edesdadesnadgaananenss 84 A ES aaa a a ner aaa a E a a aE A a A O RENEE 87 Method S aiia sinnini A A TAEA 87 A 87 PACA Da nadan 89 Factory MENOS iris CAI
30. Brush brush Draws the text filling the interior of each character with the given brush Please see Fonts and Text for a demonstration of this method gt baselineOrigin The point on the baseline to begin drawing the first character font The TrueType font to use to draw the text text The text to display as either a UTF 8 string std string or a UTF 32 string std u32string size The size of the font in pixels angle The angle in degrees at which to rotate the text VV VV WV brush The characteristics of the coloring used to fill the text Area MeasureText const Point amp baselineOrigin FiniteStreamReaderg font const std u32string amp text float size Area MeasureText const Point amp baselineOrigin FiniteStreamReader amp font const std u32stringg text float size const Stroke amp stroke Area MeasureText const Point amp baselineOrigin FiniteStreamReaderg font const std string amp text float size Area MeasureText const Point amp baselineOrigin FiniteStreamReader amp font const std string amp text float size const Stroke amp stroke Get the encompassing bounding box of the text if it were drawn to the screen This can be used to help align and Comfile Technology MoaTouch User s Manual 69 of 124 MoaTouch User s Manual position text on the screen gt baselineOrigin The point on the baseline to begin the first character font The TrueType font to us
31. CO OCON Color Jolie MESS 0x0 ORT Comfile Technology MoaTouch User s Manual 98 of 124 MoaTouch User s Manual GradientStop start 300 0 140 0 gray RadialGradientBrush brush start 280 0f blue Display a rounded rectangle with the brush Leo Erllrectengle 11300 0 140 06 200 0 200 08 20 05 brash run forever while true return 0 Comfile Technology MoaTouch User s Manual 99 of 124 MoaTouch User s Manual RTC Class This class provides access to the MoaTouch s real time clock It is implemented as a singleton class whose instance can be accessed via the rtc identifier See also the DateTime Class Methods DateTime GetDateTime Get the current date and time void SetDateTime const DateTime amp value Set the current date and time Examples See the DateTime Class Example for a demonstration of the class Comfile Technology MoaTouch User s Manual 100 of 124 MoaTouch User s Manual ScreenOrientation Enumeration An enumeration for specifying the orientation of the MoaTouch s screen See the LCD SetOrientation method Items Rotated 0 Default Screen not rotated 800 x 480 Rotate90 90 Screen rotated 90 degrees clockwise 480 x 800 Rotatel180 180 Screen rotated 180 degrees essentially appear upsided down from the default 800 x 480 Rotate270 270 Screen rotated 270 degrees or 90 degrees counter clockwise 480 x 800 Comf
32. IATA AE AE AA AAA AAA AA AA 89 COMSERUCKORS lt 5 AE ANAR TR 89 A chi cucenacsssaleathasetadssnsstetecscadecstecaintecatasananciegmenesennssiest aienaaemensacensctaneGtassiate cate dunacaaasenacenaieeanee tates 90 Operator vc RARA TAI A AAA A AAA 90 Example Pre SAO a o E 90 Example QUE a AA ESEA Aa EE aaa E EEA AA Aaa DEANE 92 Parity Enumeratio herein a bis 93 AEE EE E A E E A Deena aeR eds sea 93 n EP E E A E a E E TT 93 PISTA Tea Class lit a E A a a Ea a e de 94 CONSTRUCLO Siria A A Aa 94 A A sam E sade agusuluoe gemasnnan sania ccna laansieekileuiwrancalnceeeba daa a O AE E 94 PIRSIPOME Glassy A oda a a deeds 96 Constructors womwaeyaceadennensueened dekaceadoasscneinamdeeasieasstneaneaGuslecans 96 El iii ic 96 A A A ON 96 OPS corri NAAA ARI A AAN 96 O SS i oc icscisshecadeensiaaadadesaaan sad ancd gees aaiianemonsteane nada dsedasedehmeeeeeasaedaxadand ssacacewest aaaaeanatsaadneanetceaGs seaueaeaencncts 97 CONSULTORS oct ia 97 Fields seccicansacacsnccadeduss a A AAA ad 97 Mer sirean aa divncaceeecedee a id 97 Mi A TAAAC ENARE 97 RadialGradiemtbnushClase sic its inca ance tenes E EEA AA E EPA A A aE 98 CONSERUCLO Scissor iaa a A A A 98 Methods inasre neea esata odacauasihnee gema A a E eieuumweaneainct esta E EA EE 98 OPGKALONS iFavncinussuienys sencuagiasiajsponuanina sae seneehsinatss sicsiniatyelveie va EAA tin sea EE EEA va iielaese eects ENEE EE SEERNES eats 98 EXAMS csi ci A AAA AA AAA AAA AAA 98 RTC O ees 100 Meios iio liad
33. MoaTouch Tools lib o Rebuild workspace sections Wl whole archive lMoaTouch Wl no whole archive W1 I C Program Fil Clean workspace Output file is bin Release HelloWorld exe with size 355 11 KB Running project post build steps arm none eabi objcopy bin Release HelloWorld exe terget ihex HelloWorld hex Errors gt 0 error s nin 0 minute s 0 second s Success Select target gt Uploading the Binary to the MoaTouch Once HelloWorld hex is created it can be uploaded to the MoaTouch 1 2 5 Connect the MoaTouch to the host PC via USB and ensure dipswitch 2 is in the ON position to put it in DFU mode Power on the MoaTouch Open the MoaTouch Control Panel and verify that the MoaTouch is connected in DFU mode Brows Browse to the location of the hex file and press the Upload button to begin uploading the program to the MoaTouch The following temporary window will display to show the status of the upload process og Co i ToolsiMoaTouch Control Panel MoaTouchUpload So MoaTouchUpload v1 B8 B B A Uploading C MoaTouch Hello World WHelloWorld hex lt 329712 bytes Erasing 10M Uploading 91 When uploading is finished the program will begin executing immediately Check the Show checkbox in the MoaTouch Control Panel to show the Console Window and the Hello World message will be seen ESA LEA ones Open e 8 World World World World v Always On Top World
34. MoaTouch User s Manual High Color C Programmable Controller with Touch MoaTouch User s Manual 2014 07 03 COMPILE TECHNOLOGY Everything for Embedded Control www ComfileTech com Copyright 2014 Comfile Technology Comfile Technology MoaTouch User s Manual 1 of 124 MoaTouch User s Manual Table of Contents ESOO amina di a a a a iaa 6 SPC Sci AA ARA RARA 6 Physical COM MECH ONS aire dea ENT a 7 Expansion Digital MVO PITA ica 7 serial Analog ana Digital I O POS ii Re 8 Electrical SpecihiCatiONS sn A AA 9 USB Upload Console POR aria nas tds rica 10 Mode DIDSWIECA coi e genase 10 Miro SD Card MO sap oe 10 EN ia oi 10 PESE RA A mamanvescauammamiae dvs Mena E ianesied ds T A 10 Software Installati n csi A A E a A nena 11 Installing the Moatouch DRUIDA A a a otanenitie 11 Moatouch Comtrol PAE cc A A A A fecesagnanndnngecaeend 12 Console WII OWE pci oi dia 12 PrOGramuUpIOTAS rs ee ia id eno OE E nea 12 The Reset Buttoni cisien 226 da E nn ate aa EEE SERA ey ag ad me AON EAA OEE Head s 12 Installing MoaTouch Virtual Serial Port Console Driver arinina E oa 13 Developing Software for the MOATOUCA cocido irsinin A a a E A A 14 Editing the Source COB rr A A ni 14 Compiling the Source CO a sd 15 Linking the OBJEC PIES A ias 15 Createsa E hex File for Uploading ipese rrenen anaa ns 16 Upload tothe MOTO
35. a EAEE 100 EXAMPlOS vitoria ti RARA AAA AAA EA AAA IA AGA RA ac 100 ScreenOnientation EnUMEera ON vias as AA e 101 MOS rr acido 101 Sera POROS a nun seen bead dd saimeases maewedebtaniedaGabe vane 102 SerialPort Channel EMuUMGnrationiivvcwcsscsavcedcces ccedsawiecwemanien saa nuie tan eeenis iaaseweciuanaluuteacezcesencnedsevsaeneancteex bese 102 A RR ls tee 102 A 103 SD Gare Class iras AS nido 105 MEA Si adam 105 EX a A A di cat 106 Socket A da 108 Socket Number Enero traia ainda 108 Socket Status Enmedio 108 MES omnia inina n naa a ia dame 108 Comfile Technology MoaTouch User s Manual 4 of 124 MoaTouch User s Manual EXAMPLE iii A AAA A A AAA AAA AA AAA AAA 109 SoOlaBrUSAACIASS tii as sshansaetednastccannettens s2iaadiaaadematahstanaanme near eeeonameas I aaa RAS 111 MC OMSUMUIGEONS 2222s O a Eanan aE 111 MGGNOOS Ys sic cccev scans A A A lenges Pedeadad ca wacadenberbdesmmenneanaasaeeamanhe iawdeudand avewsudesacnan 111 OPS a a asta 111 EXP di 111 StopBits Enumeration e ccec A ENE 112 Items is 112 Sa EA E T A a E E 112 Stopwatch e PO POOPPOOO OCOO_AU O0O0OU0 0 O AR 113 CONSTRUCLO Sii dni idad 113 METAS a cda 113 EXAMI corri AE A ai A RNA RA RARA AAA 113 String FUNGOS coc in A AA AAA AAA AAA AA a 115 Siro Me A seed dacntecesdtaldagiaacmasaaeatnanmes nodascsaasamet nignetaae aA 116 KCOMSUMUIGEONS gt 2c c2cccatss echt a da seascad ned Scdadaanachaedacaasanmenanls A aaa tan ainaacnasantascktahtea space 116 MODAS uti A A 116
36. a TrueType font file and draw the characters at a specified location on the screen Text is positioned relative to its baseline origin as illustrated below Baseline Origin The MoaTouch library includes a default embedded font with ASCII characters which can be used without employing any external font files It is accessed via the defaultFont identifier This example shows how to stroke and fill text Clear the background layer led Clear Draw yellow outlined text in the default font SolidBrush yellow OxFF OxFF 0x00 Las Drente c CULO 0 WOO Oi cleicauiltcitome UW Wisieililo ala Rorzecsa als y 32 0 vella Draw green filled text in the gulim font File file sdCard Open gulim ttf SolidBrush green 0x00 OxFF 0x00 led FillText 100 0f 200 0f file GQt otAl 48 0f green sdCard Close file When loading a font from the SD Card every time text is displayed the glyphs have to be read from the file This may Comfile Technology MoaTouch User s Manual 30 of 124 MoaTouch User s Manual be fine for infrequent text updates but for highly dynamic text it may be too slow The MoaTouch supports 2 methods to remedy this Method 1 Use the BinaryToC utility to convert the font to a C source file that can be embedded into your program Please visit the MoaTouch s support website to obtain this utility and its accompanying documentation The BinaryToC program will convert the font file in
37. a std runtime error on failure void Remove const std string amp path Removes the file or folder at the given path Throws a std runtime_error on failure void Delete const std string amp path Deletes the file or folder at the given path same as Remove Throws a std runtime_error on failure Comfile Technology MoaTouch User s Manual 105 of 124 void SetOnInserted std function lt void gt value Sets the function to be called when an SD Card is inserted void SetOnEjected std function lt void gt value Sets the function to be called when an SD Card is ejected void SetOnError std function lt void const std exceptions gt value Sets the function to be called if there is an error while accessing the SD Card void Unmount Unmount the file system Example MoaTouch User s Manual This example will iterate through the file system and display the contents of each folder in a hierarchy include lt MoaTouch h gt include lt string gt include lt vector gt using namespace std using namespace MoaTouch display a message when the SD Card is inserted static void OnInserted console PrintLine SD Card Inserted display a messsage when the SD Card is ejected static void OnEjected console PrintLine SD Card Ejected Recursive function to print the contents of a folder static void PrintFolderContents const stringg path const string tab G
38. adientStop amp source Copy constructor Methods Point GetPoint const Gets the point identifying the location of this instance void SetPoint const Point amp value Sets the point identifying the location of this instance Color GetColor const Gets the color for this instance void SetColor const Color value Sets the color for this instance Operators GradientStopg operator const GradientStop source Copy assignment operator Example See the LinearGradientBrush Example and the RadialGradientBrush Example for a demonstration using this class Comfile Technology MoaTouch User s Manual 66 of 124 MoaTouch User s Manual Layer Class This is an abstract base class to provide uniform drawing features to both background layers and foreground layers It is implemented by the LCD Class and the ForegroundLayer Class Miscellaneous Methods PixelArea GetArea const Get the LCD s dimensions PixelPoint GetOrigin const Gets the origin top left corner of this layer uintl6 t GetWidth const Gets the width of this layer uintl6 t GetHeight const Get the height of this layer void Clear Clear the background layer void Clear const PixelArea amp area Clear the given area of the background layer Raster Graphics Methods void DrawImage const PixelPoint amp topLeft FiniteStreamReader amp image Plot an image to the screen with positioned with its top left corner at topLeft Please
39. as shown below TARGET_OUTPUT_ FILE and TARGET OUTPUT _BASENAME are special Code Blocks variables that refer to the executable file and the executable file name without the extension respectively Selected compiler MoaTouch Compiler Compiler settings Linker settings Search directories Pre post build steps Pre build steps arm none eabi objcopy TARGET_OUTPUT_FILE target ihex TARGET_OUTPUT_BASENAME hex Custom variables Make commands C Always execute even if target is up to date Comfile Technology MoaTouch User s Manual 23 of 124 MoaTouch User s Manual Select Build gt Build from the Code Blocks menu to build the project Build Debug Fortran wxSmith Tool J lt Build Ctrl F9 E Logs amp others Compile current file Ctrl Shift F9 E P J Code Blocks X Search results X A coc x Build log xX Build messages x gt Run Ctrl F10 f Build and run F9 P Build Release in HelloWorld compiler MoaTouch Compiler 3 Rebuild Ctrl F11 arm none esbi g exe Wall 02 mthumb 03 std c 11 mepu cortex m4 mfpu fpv4 sr Clean F include c HelloWorld cpp o obj Release HelloWorld o E arm none eabi g exe Wall 02 mthumb 03 std c 11 mepu cortex m4 mfpu fpv4 sp Build workspace include c main cpp o obj Release main o A arm none eabi g exe L C Program Files x86 ComfileTools
40. aster Class to control Comfile Technology s Moacon MD DOS08 Digital Output Source module When the operator touches one of the LEDButtons on the screen the MD DOSO8 s corresponding output state will toggle include lt MoaTouch h gt using namespace MoaTouch static volatile bool handledTouch Stat lcePOuntetoucnecle omita static Word Corone Point pf Capture the point touched by the operator touchedPoint p Let UI know that it needs to handle the touch event handledTouch false static void OnMove Point p 1f the operator s touch has not yet been handled by the UI if handledTouch II Use the atest point touched by the operator touchedPoint p static void OnRelease Point p Don t have the UI handle any more touch events handledTouch true A button that if touched will toggle the state of a ModPort output while displaying the output s state class LEDButton popite LEDButton uint8 t index ModbusRTUMaster modbus m_ index index mansa 25 0 mm imedes 100 0 SOME SOO 30205 m_modbus modbus cm stare wellse Draw the UI with the ModPort output s initial state Render Update Process the touch event bool ProcessTouch Pointg p Did the operator touch this LED poolik motes Wl ieee UMicerSecies s if isTouched Toggle the ModPort output via Modbus m_modbus gt ForceSingleCoil 1 m_index m
41. at size float angle const Stroke amp stroke const Brush amp brush void DrawText const Point amp baselineOrigin FiniteStreamReader amp font const std stringg text float size const Stroke amp stroke const Brush amp brush void DrawText const Point amp baselineOrigin FiniteStreamReader amp font const std stringg text float size float angle const Strokes stroke const Brush amp brush void DrawText const Point amp baselineOrigin FiniteStreamReader font const std u32string amp text float size const Strokes stroke const Brush brush void DrawText const Point amp baselineOrigin FiniteStreamReader font const std u32strings text float size float angle const Stroke amp stroke const Brush brush void DrawText const Point amp baselineOrigin FiniteStreamReader font const std string amp text float size const Stroke amp stroke const Brush amp brush void DrawText const Point amp baselineOrigin FiniteStreamReader font const std string amp text float size float angle const Strokes stroke const Brush amp brush Draw the outline of text Please see Fonts and Text for a demonstration of this method baselineOrigin The point on the baseline to begin drawing the first character font The TrueType font to use to draw the text text The text to display as either a UTF 8 string std string or a UTF 32 string std u32string size T
42. ce Code We create 3 files with our text editor all in the same folder gt HelloWorld h The header file for the HelloWorld class gt HelloWorld cpp The implementation file for the HelloWorld class gt main cpp The entry point of our program HelloWorld h ifndef HELLOWORLD H define HELLOWORLD H class HelloWorld publi void SayHello 7 endif HelloWorld cpp include lt cstdio gt Jil Oe joxesliniese include HelloWorld h void HelloWorld SayHello printf Hello World main cpp include lt MoaTouch h gt tinclude HelloWorld h using namespace MoaTouch int main HelloWorld hw create an instance of the HelloWorld class loop forever while true hw SayHello call the SayHello method to print to standard output Delay ms 500 delay for 500ms Comfile Technology MoaTouch User s Manual 14 of 124 MoaTouch User s Manual Compiling the Source Code In the Windows Start Menu under Comfile Tools you ll find a link to MoaTouch GNU Toolchain This runs a batch file that adds the toolchain s bin folder to the host PC s path variable IM El MoaTouch GNU Toolchain Click it and a console window will open Change directory cd to the folder containing the source code Then type the following commands to compile the source code arm none eabi g c mthumb mcpu cortex m4 mfpu fpv4 sp d16 mfloat abi softfp fsingle precision constant ff
43. cting the green background layer Display a green rectangle SolidBrush green 0x00 OxFF 0x00 Ll ecc cn ls 10 O 100 200 0 Sne Spas y White Text File file sdCard Open file dejavu ttf SolidBrush white OxFF OxFF OxFF Create foreground layer ForegroundhLayer amp fg lcd CreateForegroundLayer 40 0f 20 0f 70 0f 40 0f White Text File file sdCard Open amp file dejavu ttf SolidBrush white OxFF OxFF OxFF Hie Display 123 fo Drawlext 50 0 S0 0f file L23 32 0 white Clear 123 Transparent for foreground layer fg Clear Display 456 fo Drawrext HO sO DOS Fale WHY IAS Wine e ji closer font fale sdCard Close file 456 That s better One could have simply displayed a new green filled rectangle to clear the text in this example but that method falls short for backgrounds that may be images Images are stored on the SD card and reading from the SD card is orders of magnitude slower than drawing with the CPU Re displaying the background image from the SD card for each and every text update especially if the image were full screen would be much too slow to be practical and this is why the layering feature was created Layers and Memory Creating layers requires memory to hold the state of its pixels The MoaTouch has 4MB of memory that is shared by all layers cached fonts and any other loadable content When the MoaTouch is first powered o
44. cutable Comfile Technology MoaTouch User s Manual 15 of 124 Create a hex File for Uploading MoaTouch User s Manual Once HelloWorld elf is created we need to create a hex file that the MoaTouch Control Panel can upload to the MoaTouch arm none eabi objcopy HelloWorld elf target ihex HelloWorld hex Upload to the MoaTouch Once HelloWorld hex is created it can be uploaded to the MoaTouch 1 Connect the MoaTouch to the host PC via USB and ensure dipswitch 2 is in the ON position to put it in DFU mode 2 Power on the MoaTouch 3 Open the MoaTouch Control Panel and verify that the MoaTouch is connected in DFU mode 4 Browse to the location of the hex file and press the Upload button to begin uploading the program to the MoaTouch The following temporary window will display to show the status of the upload process MoaTouchUpload v1 6 6 6 fh Tools MoaTouch Control Panel MoaTouchUpload S Uploading C MoaTouch Hello World HelloWorld hex 329712 bytes Erasing 106 Uploading 91 5 When uploading is finished the program will begin executing immediately Check the Show checkbox in the MoaTouch Control Panel to show the Console Window and the Hello World message will be seen ya co cara EA ones Open World World World World World World World World World World World World World World World World World World World World World World W
45. daa 16 Configuring a Software Integrated Development Environment IDE ococcncococoncnnncononencannosnononcnnananrnonnrararanencanacasa 17 CONQUE COMPUSO EA a E 17 Creating a New PrOJOCl amara A pang a a AA 19 Adding Source Code Files to the Project siisii aaan RSS Aaa di 21 Building tHe PROVSCE sn scada aia Ena RTS AAA Aa 23 Uploading the Binary tothe MOaTOuGM obra 24 CODI ACASO EA 25 TO 28 MOCHOLEPAPIMOS caro ii A de 28 Raster Grab MES liar 29 Fonts AME TERE o o dies 30 CAYOS iii A ei a AA 32 Using layers to Update FE ad 33 o A a A SeaadestdaadiedneananeaeteraeeTeas 33 ATOM Li A ad a 33 ENAA LEN PINE PFEIFER TITTIE eceadedscdeseds agagnaaenemansdadadeedencba seis tananaseesese oad concdesdendiaaqaaecmenanaeanedeensns 34 Layers ara MEMORY ina a aa DE ES 34 Calibrating the Touch Saree sz an e Ea as 35 CLASS REE e E AE 36 An PULICAR e 36 AMO OUEN ARS 36 Methods om al dd 36 EXA id A A in 36 A aloqUnputs Clas ns A A o arca 38 DPS a aa jade 38 SA A ARA 39 COMSERU CHONG IS 39 MONOS ii a A A T 39 BiiShClaSS ii a A E E A A 41 MOI iv a ans ARS 41 BUS dae 42 MODAS tae 42 SN 42 Brushy pe ENUMERAN aiii A A AA e nara didas 43 TAO ir a daa ee naan 43 Color as A naaa 44 COMSEMUCHONS iniii canini a AERES sesame dhadnencue sual arehaananan rs a E ARANEO 44 MODAS E daa 44 AMO sriscshecs assets eenanscuntaanaieatstaaeds ieauee wan tnanie dani aagerescedadg qu Aa A sag gu ibaa Aa a 45 CONSPRUCLOES rd ira E REA AD a edad daci n 45 Un cetece
46. ds This class implements all of the Layer Class s Miscellaneous Methods in addition to the methods below bool IsEnabled const Returns true if this layer is enabled void Enable bool enable Enables this layer so its contents are flushed to the LCD screen void Disable bool disable Enables this layer so its contents are not to the LCD screen void SetLeft const PixelCoordinate x Relocates the left coordinate of this layer effectively moving the layer horizontally void SetTop const PixelCoordinate y Relocates the top coordinate of this layer effectively moving the layer vertically void SetTopLeft const PixelPoint amp value Relocates the top left coordinate of this layer effectively moving the layer float GetAbsoluteX float relativeX const Given an x coordinate relative to this layer s origin returns the absolute x coordinate relative to the screen s origin float GetRelativeX float absoluteX const Given an x coordinate relative to the screen s returns the x coordinate relative to this layer s origin float GetAbsoluteY float relativeY const Given a y coordinate relative to this layer s origin returns the absolute y coordinate relative to the screen s origin float GetRelativeY float absoluteY const Given a y coordinate relative to the screen s returns the y coordinate relative to this layer s origin Point GetAbsolutePoint const Points relativePoint const Given a point relative to this
47. e Reads a single byte from the receive buffer Returns the byte read from the receive buffer or a negative number if the receive buffer is empty size_t Write const void buffer size_t numOfBytes Copy numOfBytes bytes from buffer to this socket s transmit buffer Returns the number of bytes actually written size_t WriteByte uint8 t value Writes a single byte to the transmit buffer Returns the number of bytes actually written Example The following example is a simple web server that prints Hello from the MoaTouch to a visiting web browser include lt MoaTouch h gt using namespace MoaTouch int main Configure the Ethernet interface ethernet SetHardwareAddress 0xAA OxBB OxCC OxDD OXEE OxFF ethernet SetIPAddress 192 168 0 252 ethernet SetSubnetMask 255 255 255 0 ethernet SetGateway 192 168 0 2 Use Socket 0 Socket amp socket ethernet GetSocket Socket Number S0 The string to send to the client string hello Hello from the MoaTouch Run forever while true Get the socket s connection status Socket Status status socket GetStatus switch status If closed open case Socket Status Closed socket Open 8080 break If Initialized listen for an incoming connection case Socket Statusi IMIE socket Listen break When connection is establisheded send response and disconnect case Socket Status Established sock
48. e Process id Ww ane iw WA ADC t T 3 Aan Nx i Analog Input Comfile Technology MoaTouch User s Manual 9 of 124 MoaTouch User s Manual MicroSD Slot D Mode a Dipswitch 5 Reset Ethernet Switch USB Upload Console Port This USB port functions as either a virtual serial port console or a program upload port port depending on the state of the Mode Dipswitch Mode Dipswitch gt Dipswitch 1 Reserved for future use gt Dipswitch 2 Switches between DFU Mode On and Console Mode Off o DFU Mode In this mode when the MoaTouch is first powered on it will appear to the host PC as DFU Na device so programs can be uploaded to it See Installing the MoaTouch DFU Driver for further gt instructions o Console Mode In this mode when the MoaTouch is first powered on it will bypass DFU mode and begin executing the last program that was uploaded to it The program can then send messages to the host PC for monitoring and debugging See Installing MoaTouch Virtual Serial Port Console Driver for further instructions Micro SD Card Slot Accepts a FAT32 formatted Micro SD Card for storing user data Long file names are not supported which implies the following limitations gt File names are limited to an 8 character name and a 3 character extension a k a 8 3 format gt Files created by the MoaTouch will appear in all upper case letters despite having specified lower case lette
49. e const Returns true if the given coordinate lies above this area bool IsOffTopLeftBound const Point amp point const Returns true if the given point is either to the left of this area above this area or both bool IsWithinHorizontalBounds int16_t value const Returns ture if the given coordinate is greater than or equal to the left coordinate of this area and less than or equal to the right coordinate of this area bool IsWithinVerticalBounds int16_t value const Returns true if the given coordinate is greater than or equal to the top coordinate of this area and less than or equal to the bottom coordinate of this area void SetHeight uintl6 t value Sets the height of this area void SetLeft int1l6 t x Sets the left most x coordinate of this area Setting this value does not change the width or height of this area It effectively moves the area along the x axis void SetTop int16 t y Sets the top most y coordinate of this area Setting this value does not change the width or height of this area It effectively moves the area along the y axis void SetTopLeft const Point value Sets the top left corner of this area Setting this value does not change the width or height of this area It effectively shifts the area to a new location void SetWidth uint16_t value Sets the width of this area Comfile Technology MoaTouch User s Manual 95 of 124 MoaTouch User s Manual PixelPoint Class Represents a point in a 2 d
50. e second text will be superimposed on the first text as shown below Display a green rectangle SolidBrush green 0x00 OxFF 0x00 Tedi a liceo remo le OO DIO A002 TsO ceeam 9 White Text File file sdCard Open amp file dejavu ttf SolidBrush white OxFF OxFF OxFF Display 123 Ted Drets SO 0 SO Oi isle Vil2sv S2 Oi1e Waste Display 456 cel Dreayiresas SO 0 SO Ow wile VASE 32 0 wines 5 close tome alle sdCard Close file 426 Attempt 2 If a call to LCD Clear is used in between the two LCD FillText function calls the background will be erased and a black box will appear which is also not desirable Display a green rectangle SolidBrush green 0x00 OxFF 0x00 cel Rec le 0 Gi DIE 200 0 TES Easy White Text File file sdCard Open amp file dejavu ttf SolidBrush white OxFF OxFF OxFF Display 123 cel Dread 50 0 SOQ Or B le Migs 32 0 wilouliesy 5 Clear the box containing the text black on background layer eel Cilscuc AO Oi 20 0 70 0 40 05 e Display 456 cl Drawrext SOR OE ys 500 Erne 4 SIG Nese Ore Voita Ii closs eme lle sdCard Close file 456 Comfile Technology MoaTouch User s Manual 33 of 124 MoaTouch User s Manual Attempt 3 However by separating the green background and the text onto different layers clearing the foreground layer containing the text will clear the text without impa
51. e if the current output state is logic low void On bool on true Sets the current output state to logic high on true or logic low on false void Off bool off true Sets the current output state to logic low off true or logic high off false void High bool high true Sets the current output state to logic high high true or logic low high false void Low bool low true Sets the current output state to logic low low true or logic high low false void Toggle Toggles the current output state Comfile Technology MoaTouch User s Manual 58 of 124 MoaTouch User s Manual ExDigitalOutputs Class This class simply provides indexers for retrieving the ExDigitalOutput Class instances Operators ExDigitalOutput amp operator ExDigitalOutput Pin pin const Returns the ExDigitalOutput Class instance assigned to the given pin ExDigitalOutput amp operator int index const Returns the ExDigitalOutput Class instance at the given index Will throw a std out_of range exception of index is invalid Comfile Technology MoaTouch User s Manual 59 of 124 MoaTouch User s Manual File Class This class is used with the SDCard Class to do file I O It inherits from the FiniteStreamReader Class Methods void Flush Flush any cached data to disk Throws a std runtime error on failure size_t GetCurrentPosition Reports the current position in the file Throws a
52. e rectangle lcd DrawRectangle 50 0f 100 0f 150 0f 200 0f stroke cyan sw Stop stop counting display result console PrintLine Sf microseconds sw GetElapsedMicroseconds run forever while true return 0 Console window output 6 301357 milliseconds Comfile Technology MoaTouch User s Manual 114 of 124 MoaTouch User s Manual String Functions The current MoaTouch toolchain does not fully support C99 and therefore does not support the C 11 std to string std stoi std stol std stof etc methods other C 11 features are supported however To compensate for this and to provide a convenient Unicode conversion the following functions are available as free functions in the MoaTouch namespace tring ToString int value tring ToString long value tring ToString long long value tring ToString unsigned value tring ToString unsigned long value tring ToString unsigned long long value tring ToString float value 0 0 0 000 000 0 0 tring ToString double value nn DNA HH HN WN ct Q td string ToString long double value Converts numbers to a decimal string representation Alternatively users can always use the C sprintf function to convert a number to a string Using stringstream or any of the other C io stream features are not recommended as they drastically increase code size int ToInt const std string amp s size_t pos 0 int base 10 Parses
53. e s line cap end cap LineJoin GetJoin const Gets the shape of the line joints for this stroke void SetJoin LineJoin value Sets the shape of the line joints for this stroke Operators Stroke amp operator const Stroke amp source Copy assignment operator Example See the LineCap Enumeration Example and the LineJoin Enumeration Example for a demonstration of this class Comfile Technology MoaTouch User s Manual 116 of 124 MoaTouch User s Manual System Class This class provides access to some general features for controlling the MoaTouch It is implemented as a singleton accessible via the system identifier Methods void Reset Perform a software reset void Enablelnterrupts bool enable true Enable interrupts void DisableInterrupts bool disable true Disable interrupts std function lt void const std exception amp gt GetOnUnhandledException const Gets the function to call if an unhandled exception occurs void SetOnUnhandledException std function lt void const std exception amp gt value Sets the function to call if an unhandled exception occurs void AtomicCall std function lt void void gt f void args Runs the given function with arguments args at a high priority so it cannot be interrupted uint32 t GetLibraryMajorVersion const Gets the major version number of the MoaTouch library uint32_t GetLibraryMinorVersion const Gets the minor version number
54. e to determine the shape the text text The text to measure as either a UTF 8 string std string or a UTF 32 string std u32string size The size of the font in pixels vyv Vv stroke The characteristics of the line used to outline the shape of the characters Comfile Technology MoaTouch User s Manual 70 of 124 MoaTouch User s Manual LCD Class This class is used display 2 D graphics on the MoaTouch s LCD screen All drawing functions draw to the main background layer Additional layers can be created with the CreateForegroundLayer method This class is implemented as a singleton that can be accessed via the 1cd identifier This class implements the Layer Class and all of its methods Miscellaneous Methods This class implements all of the Layer Class s Miscellaneous Methods in addition to the methods below ScreenOrientation GetOrientation const Gets the screen orientation See the ScreenOrientation Enumeration void SetOrientation ScreenOrientation orientation Sets the screen orientation See the ScreenOrientation Enumeration void DisableFlush bool disable true Disable flushing the frame buffer to the LCD If you have many items to draw use this to prevent displaying each item on the screen until all items have been drawn Using this command in combination with EnableFlush can improve performance and prevent display anomalies while drawing void EnableFlush bool enable true Enable flushin
55. e top most y coordinate of this area Setting this value does not change the width or height of this area It effectively moves the area along the y axis void SetTopLeft const Point value Sets the top left corner of this area Setting this value does not change the width or height of this area It effectively shifts the area to a new location void SetWidth float value Sets the width of this area Comfile Technology MoaTouch User s Manual 40 of 124 MoaTouch User s Manual Brush Class This is an abstract class that provide a uniform implementation for all brushes It is implemented by the SolidBrush Class the LinearGradientBrush Class and the RadialGradientBrush Class Methods virtual BrushType GetType const 0 Gets this instance s BrushType for distinguishing it from other brushes Comfile Technology MoaTouch User s Manual 41 of 124 MoaTouch User s Manual Buzzer Class The MoaTouch contains a small piezo buzzer that can be used for audio feedback It is implemented as a singleton class whose instance can be accessed via the buzzer identifier Methods float GetFrequency const Gets the frequency in hertz of the sound to emit bool IsOff const Returns true if the buzzer is currently off not emitting sound bool IsOn const Returns true if the buzzer is currently on emitting sound void Off bool off true Turns the buzzer off The off argument is optional If off is true the buzzer will
56. ember this value for comparisons next time previousValue currentValue Convert value to a string representation string s ToString currentValue GetYear Y ToString currentValue GetMonth ToString currentValue GetDayOfMonth uw ToString currentValue GetHours PadZeros currentValue GetMinutes PadZeros currentValue GetSeconds SolidBrush white OxFF OxFF OxFF col iva ilies LOO Oi 1000 ceicemikciiontc y 3200 Wales y Enable updating changes on the screen lced EnableFlush Wait for all changes to be drawn while lcd HasChanges return 0 2014 4 30 4 03 39 Comfile Technology MoaTouch User s Manual 49 of 124 MoaTouch User s Manual Delay Functions The following functions provide the ability to pause execution for a short period of time They simply forward to the corresponding static functions in the Stopwatch Class and therefore carry the same limitation that they cannot be used to delay for durations longer than 50 seconds void Delay _us float us Delay for the given number of microseconds void Delay _ms float ms Delay for the given number of milliseconds void Delay s float s Delay for the given number of seconds Comfile Technology MoaTouch User s Manual 50 of 124 MoaTouch User s Manual DigitalInput Class The MoaTouch has 4 GPIO digital inputs This class provides access to those inputs Instances of
57. emonstration of this method void DrawCircle const Pointg center float radius const Stroke amp stroke const Brush amp brush Draw the perimeter of a circle at center with the given radius using the given stroke and brush See Example Circles and Ellipses for a demonstration of this method void FillCircle const Pointg center float radius const Brushg brush Fill a circle at center with the given radius using the given brush See Example Circles and Ellipses for a demonstration of this method void DrawArc const Point amp center float radius float startAngle float sweep const Strokeg stroke const Brush brush Draw an circular arc starting at startAngle traveling sweep degrees using the given stroke and brush Positive numbers sweep in the clockwise direction Negative numbers sweep in the counter clockwise direction See Example Arcs for a demonstration of this method void DrawArc const Point amp center float horizontalRadius float verticalRadius float startAngle float sweep const Stroke amp stroke const Brush amp brush Draw an elliptical arc starting at startAngle traveling sweep degrees using the given stroke and brush Positive numbers sweep in the clockwise direction Negative numbers sweep in the counter clockwise direction See Example Arcs for a demonstration of this method void DrawCurve const Point amp from const Point amp control const Pointg to const Stroke amp stroke c
58. ength Example Please see the SerialPort Class Example for a demonstration of this enumeration Comfile Technology MoaTouch User s Manual 47 of 124 MoaTouch User s Manual DateTime Class This class representing a calendar point in time It is the type returned from the real time clock RTC Class Constructors DateTime Instantiates this instance defaulting to January 1 1900 DateTime uint16_t year uint8 t month uint8 t dayOfMonth uint8 t hours uint8 t minutes uint8 t seconds Instantiates this instance with the values given If any value is invalid range error exception is thrown DateTime const DateTimes Copy constructor Methods uint8 t GetDayOfMonth const Gets the day of the month component 1 31 uint8 t GetHours const Gets the hours component 0 23 uint8 t GetMinutes const Gets the minutes component 059 uint8 t GetMonth const Gets the month component 1 12 uint8 t GetSeconds const Gets the seconds component 0 59 uintl6 t GetYear const Gets the year component 1900 2099 void SetDayOfMonth uint8 t value Sets the day of the month component 1 31 range error exception is thrown if value is invalid void SetHours uint8 t value Gets the hours component 0 23 range error exception is thrown if value is invalid void SetMinutes uint8 t value Sets the minutes component 0 59 range error exception is thrown if value is inva
59. erage is 50 Since a single pixel is the smallest individual unit of color the graphics engine approximates the 50 pixel coverage by making the pixel half as bright i e 50 transparent That is why on a black background the line appears gray instead of white In summary sub pixels are approximated by varying the pixel s brightness according to the percentage of pixel s area covered by the shape All this is necessary in order to support anti aliasing and ensure the visuals appear smooth and professional DOG Anti aliased Aliased Comfile Technology MoaTouch User s Manual 26 of 124 MoaTouch User s Manual If an application requires a horizontal line that is exactly 1 0 pixel thick and not approximated on the pixel grid simply shift the line as necessary to achieve 100 pixel coverage In the following example the horizontal line in the previous illustrations is shifted up by 0 5 pixels to get 100 pixel coverage on row 2 SolidBrush white 0xFF OxFF OxFF Stroke stroke 1 0 LineCap Butt LineJoin Round Lcd Dramas 20 Loi 12 Oke LoS stroke white ERR Line Thickness 1 0 Row 2 Pixel Coverage 100 k Now because the pixel coverage is 100 the pixels will be lit at 100 brightness i e 100 opaque resulting in a bright white horizontal line with a thickness of exactly 1 0 pixel Comfile Technology MoaTouch User s Manual 27 of 124 MoaTouch User s Manual Graphics The MoaTouch can display
60. es it reads while the user is touching the screen When the user releases their touch it will remember the average value and display the next point to be touched After all 5 points have been read the Touch Calibration function will calibrate the touch screen and return The result of the calibration is saved in a special EEPROM so users will not need to recalibrate between power cycles If the program changes the screen orientation the touch screen will need to be recalibrated The following is a simple example illustrating the procedure in code include lt MoaTouch h gt using namespace MoaTouch static void DrawCrosshairs Point p led Clear clear the screen between each point Configure the appears of the crosshairs SolidBrush white OxFF OxFF OxFF Stroke stroke 2 0 LineCap Butt LineJoin Round loss machiis OOE draw the vertical line Bada danei sedas siene 9 190 eebe oak 199 Eachlus 2 lcd DrawPath linel stroke white draw the horizontal line Bara imss arnas aae oes gt acusa JU oaks RECO TDS lcd DrawPath line2 stroke white int main touch Calibrate DrawCrosshairs perform the calibration lcd Clear clear the screen while true loop forever return 0 Comfile Technology MoaTouch User s Manual 35 of 124 MoaTouch User s Manual Class Reference AnalogInput Class The MoaTouch has four 12 bit analog inputs This class provides access
61. et PrintLine HTTP 1 0 200 OK socket PrintLine Content type text socket PrintLine Content Length ToString hello length socket PrintLine socket Print hello socket Disconnect break default break Comfile Technology MoaTouch User s Manual 109 of 124 MoaTouch User s Manual return O lt See screenshot on next page gt gt C EXE Hello frorn the MoaTouch Comfile Technology MoaTouch User s Manual 110 of 124 MoaTouch User s Manual SolidBrush Class This class is used with the various drawing features of the MoaTouch to display shapes in a solid color This class implements the Brush Class Constructors SolidBrush const Color amp color Create a new instance of this class specifying the color SolidBrush const SolidBrush amp source Copy constructor Methods Color GetColor const Gets the color currently used for this brush void SetColor const Color value Sets the color to use for this brush BrushType GetType const Returns the BrushType Solid to identify this brush as a solid color brush Operators SolidBrushg operator const SolidBrushg source Copy assignment operator Example This example will display a partially transparent fuchsia filled rectangle on an opaque green filled rectangle include lt MoaTouch h gt using namespace MoaTouch int main start off with a blank screen led SetBacklightB
62. et all the children in folder path vector lt FileInfo gt children sdCard GetChildren path children iterate through all of the children for FileInfo c children Print the file folder name console Print tab console PrintLine c GetName Ti a folder print its contents aie es siatellieleue PrintFolderContents path c GetName tab il woo int main sdCard SetOnInserted OnInserted display a message when card is inserted sdCard SetOnEjected OnEjected display a message when card is ejected while sdCard IsInserted wait for card to be inserted sdCard Mount Mount the filesystem PrintFolderContents Print the contents of the filesystem starting at Comfile Technology MoaTouch User s Manual 106 of 124 MoaTouch User s Manual sdCard Unmount umount the filesystem while true run forever return 0 Console window output SD Card Inserted LEVEL1 ETLE TXT FILE TXI FILE2 TXT LEVEL2 FILE3 TXT cal ar FILE2 TXT ETES TXI IP TXT FILES TXT SD Card Ejected Comfile Technology MoaTouch User s Manual 107 of 124 MoaTouch User s Manual Socket Class An individual TCP IP socket for performing communication over the MoaTouch s Ethernet port The MoaTouch has 4 sockets Socket Number Enumeration An enumeration for identifying an individual serial port channel Socket Sta
63. ethods iiccccexscaasudhosucusiul aai EE a AAA E TE A A A AEE a IRATE U ONEA 57 OPALO S cies 57 EXDigitalOutput Class a A iii 58 ExDIgitalOut putes Pim EU Md as 58 A shave aE aaa had aac amsaaaeananinanase eames eucten sane team cee ness anteeeece haa ania nhc daa A A ORTA 58 ExDigitalOutputs ClaSS comia A A pacacagagameeseacneans 59 Mi e tes e iein a rAr arao ainei E e ETa ai ie E S ENTARA 59 Bile Glass an o ic 60 Method Sheo a EE a Aa E EE E EE E ENE E EAN EAEE Sa ua 60 e E cadeasadaatiamcaeeneaaedGenaew areas diousadbensaseniedediteaes saadee aad iweesauates 60 Edito Clas A ea 62 A ts cnet catiscsleteaaaneadaresscedcascadlcatenainencetasnansacegseseesesassset saeetadmensaeeteccattacasaseiesaceattarmnasenasaneooreses tater 62 Si OA 62 FiniteStreamReader ClaSS cian cidad Ad A ENARA 63 MA A ihcuGdadahendetseuwea daemon ata baguadaus debacmaa EAA ENE 63 FoOregroundlaVer GlaSS dias 64 Miscellaneous Methods os 000 A 64 Raster Graphics Methods ooo A RA A A nigeenaees 64 Vector Graphics Methods 00 corro A A a Aa 64 Text Methods iii Anna 65 GradienESto iC lassie 2 OPC nO II O 66 CONSUL Si a EA 66 MES 5 svsaceisentesd ceasentcnsanteninintaceestentsd vaacticeensnaan nis aatemne nes Sadaabecumeunedeniiived baka ceaadi ase EOE ARRET R 66 OPAT S iii a te ta taihidiaatantaasiasagassesios ssi ialaaiaanenesianaeneanece 66 Sl ON 66 Layer Clas aiii ci E AAA AER EAST AAA DARA A ARS 67 Miscellanecus Methods nd A iaa 67 Raster Graphics MGthOOS aci a A ines
64. function lt void uint32_t gt value Sets the function to be called when one of the inputs state changes uint32 t GetState const Returns the state of all 32 inputs The least significant bit is bit ExDigitalInput Pin Operators ExDigitalInputg operator ExDigitalInput Pin pin const Returns the ExDigitalInput Class instance assigned to the given pin ExDigitalInput amp operator int index const MoaTouch User s Manual IO Returns the ExDigitalInput Class instance at the given index Will throw a std out_of range exception of index is invalid Comfile Technology MoaTouch User s Manual 57 of 124 MoaTouch User s Manual ExDigitalOutput Class The MoaTouch has 32 expansion digital outputs This class provides access to those outputs Instances of this class can be retrieved via the exDigitalOutputs int index or exDigitalOutputs ExDigitalOutput Pin pin indexers ExDigitalOutput Pin Enum An enumeration for identifying an individual digital input channel 00 031 Methods static ExDigitalOutput GetInstance Pin pin Get the instance of this class for the given pin Pin GetPin const Returns the ExDigitalOutput Pin assignment for this instance bool IsHigh const Returns true if the input is a logic high bool IsLow const Returns true if the input is a logic low bool IsOn const Returns true if the current output state is logic high bool IsOff const Returns tru
65. g Pixels This example draws a small checkerboard pattern in the upper left quadrant of the screen include lt vector gt include lt MoaTouch h gt using namespace std using namespace MoaTouch ae enla specifiy colors Color mc Sc O HENO 0 OO OLOl ie Color black 0700 0200 0200 create a patter for odd and even rows vector lt Color gt oddRow red black red black red black red vector lt Color gt evenRow black red black red black red black display the pattern woe ocle tc i Og a Ge a w 2 led SetPizels 100 100 at mo cddRow r La SetPixels 100 100 al 1 Susana e run forever while true return 0 Zoomed in 12x Comfile Technology MoaTouch User s Manual 76 of 124 MoaTouch User s Manual LinearGradientBrush Class This class is used with the various drawing features of the MoaTouch to display shapes in a 2 color linear gradient This class implements the Brush Class Constructors LinearGradientBrush Instantiates a new uninitialized instance of this class LinearGradientBrush const GradientStop amp start const GradientStop amp end Instantiates an instance of this class with the given start and end GradientStops LinearGradientBrush const LinearGradientBrush amp source Copy constructor LinearGradientBrush amp operator const LinearGradientBrush source Copy assignment operator Methods MoaTouch
66. g the frame buffer to the LCD bool IsFlushEnabled const Returns whether or not flushing from the frame buffer to the LCD is enabled bool HasChanges const Returns true if there are changes in the frame buffer that have not yet been flushed to the LCD void SetBacklightBrightness const uint8 t value Set the brightness of the LCD backlight 0 off 255 maximum brightness ForegroundLayer amp CreateForegroundLayer const PixelArea amp area Create a new foreground layer at the specified area This command dynamically allocates memory to hold the layer s frame buffer so be aware that creating too may layers or too large of a layer can result in memory errors See Layers for a demonstration of this method void DestroyForegroundLayer ForegroundLayer amp layer Destroy the given foreground layer deallocating its frame buffer ForegroundLayer amp GetForegroundLayer unsigned int index const Get the foreground layer at the given index Raster Graphics Methods This class implements all of the Layer Class s Raster Graphics Methods Vector Graphics Methods This class implements all of the Layer Class s Vector Graphics Methods Text Methods This class implements all of the Layer Class s Text Methods Comfile Technology MoaTouch User s Manual 71 of 124 MoaTouch User s Manual Example Arcs include lt MoaTouch h gt using namespace MoaTouch int main draw a green circular arc 1
67. he size of the font in pixels angle The angle in degrees at which to rotate the text stroke The characteristics of the line used to draw the outline of the text VV VV VV WV brush The characteristics of the coloring used to draw the outline of the text void FillText const Point amp baselineOrigin FiniteStreamReader amp font const std u32string text float size const Brush amp brush void FillText const Point amp baselineOrigin FiniteStreamReader amp font const std u32string amp text float size float angle const Brush amp brush void FillText const Point amp baselineOrigin FiniteStreamReader amp font const std string text float size const Brush amp brush void FillText const Point amp baselineOrigin FiniteStreamReader amp font const std string text float size float angle const Brush brush void FillText const Point amp baselineOrigin FiniteStreamReader font const std u32string amp text float size const Brush amp brush void FillText const Point amp baselineOrigin FiniteStreamReader font const std u32string amp text float size float angle const Brush amp brush void FillText const Point amp baselineOrigin FiniteStreamReader font const std string text float size const Brush amp brush void FillText const Point amp baselineOrigin FiniteStreamReader font const std string text float size float angle const
68. iform corner radii using the given stroke and brush void FillRectangle const Area amp area const Brush amp brush Fill a rectangle encompassing the given area using the given brush Please see Example Rectangles for a demonstration of this method Comfile Technology MoaTouch User s Manual 67 of 124 MoaTouch User s Manual void FillRectangle const Area amp area float cornerRadius const Brush amp brush Fill a rounded rectangle encompassing the given area with a uniform cornerRadius using the given brush Please see Example Rectangles for a demonstration of this method void FillRectangle const Area amp area float topLeftCornerRadius float topRightCornerRadius float bottomLeftCornerRadius float bottomRightCornerRadius const Brush amp brush Fill a rounded rectangle with nonuniform corner radii using the given brush void DrawEllipse const Point amp center float horizontalRadius float verticalRadius const Strokes stroke const Brush amp brush Draw the perimeter of an ellipse at center with the given horizontalRadius and verticalRadius using the given stroke and brush See Example Circles and Ellipses for a demonstration of this method void FillEllipse const Point center float horizontalRadius float verticalRadius const Brush amp brush Fill an ellipse at center with the given horizontalRadius and verticalRadius using the given brush See Example Circles and Ellipses for a d
69. ile Technology MoaTouch User s Manual 101 of 124 MoaTouch User s Manual SerialPort Class This is the class used for programming the MoaTouch s 4 serial ports Each port is implemented as a singleton accessible via the serialPorts identifier The MoaTouch has 2 RS 485 ports serialports 0 1 and 2 RS 232 ports serialPorts 2 3 SerialPort Channel Enumeration An enumeration for identifying an individual serial port channel Methods Channel GetChannel const Gets the channel associated with this serial port uint32 t GetBaudRate const Gets the baud rate for this serial port void SetBaudRate const uint32_t value Sets the baud rate for this serial port Parity GetParity const Gets the parity setting for this serial port See the Parity Enumeration void SetParity const Parity value Sets the parity setting for this serial port See the Parity Enumeration DataBits GetDataBits const Gets the data bits setting for this serial port See the DataBits Enumeration void SetDataBits const DataBits value Sets the data bits setting for this serial port See the DataBits Enumeration StopBits GetStopBits const Gets the stop bits setting for this serial port See the StopBits Enumeration void SetStopBits const StopBits value Sets the stop bits setting for this serial port See the StopBits Enumeration size_t GetRxCapacity const Gets the receive buffer capacity for this serial port a
70. ile code when executed pa __ In C mode support all ISO C90 programs In C mode remove GNU extensions that conflict with ISO C __ Enable all common compiler warnings overrides many other settings Wall Enable extra compiler warnings Wextra __ Stop compiling after first error Wfatal errors _ Inhibit all warning messages w Batch builds Have g follow the 1998 ISO C language standard std c 98 _ Have g follow the coming C 0x ISO C language standard std c 0x Have g follow the C 11 ISO C language standard std c 11 Warn if 0 is used as a null pointer constant Wzero as null pointer constant Enable warnings demanded by strict ISO C and ISO C pedantic Trast se arraro the wsrninne demanded hu ctrit TEN O and TEN Pis Ponadamtic arrarel NOTE Right click to setup or edit compiler flags The MoaTouch compile is a variant of the GNU GCC Compiler for ARM so select that compiler and click the Copy button This will prompt you to enter a new name for the compiler Enter MoaTouch Compiler Add new compiler Please enter the new compiler s name MoaTouch Compiler oK Cancel In the list of Compiler Flags check the following options Y Have g follow the C 11 ISO C language standard std c 11 Y Generate code that executes in Thumb state mthumb and add the following options to the Other Flags tab Compiler Flags Other option
71. image file support MicroSD Card with FAT32 file system support Field upgradable firmware VVV VV VV VV VV VV VV pecifications 16 bit color 800x480 or 480x800 7 TFT LCD 4 wire Resistive Touch Screen 168MHz ARM Cortex M4F MCU 4MB RAM 512 bytes of non volatile memory 2 RS 232 Serial Ports 2 RS 485 Serial Ports 36 Digital Inputs w Interrupt 36 Digital Outputs 4 12 bit Analog Inputs Optional 1 MicroSD Card Slot 1 USB Console Firmware Update Port 1 Ethernet Port VVVVV VV VV VV VV Y Comfile Technology MoaTouch User s Manual 6 of 124 Physical Connections Expansion Digital I O Ports Expansion Digital I O Ports O and 1 in code exDigitalInputs and exDigitalOutputs are connected to the host processor over an I C bus The other Digital I O port in code digitalInputs and digitaloutputs are connected direction to the host processor s GPIO pins Expansion Digital I O Port O P Pin 2 MoaTouch User s Manual in 40 Expansion Digital I O Port 0 Expansion Digital I O Port 1 Pin 1 10 19 28 30 39 Ground Pin 29 40 V Source Voltage Pin 2 9 exDigitalInputs 0 7 exDigitalInputs 16 23 Pin 11418 exDigitalInputs 8 15 exDigitalInputs 24 31 Pin 20 27 exDigitalO0utputs 0 7 exDigitalOutputs 16 23 Pin 31 38 exDigitalOutputs 8 15 exDigitalOutputs 24 31 Input Output ae oe oe eS Se en eee A 410 06 2 1 16 104 9 G 1 3 5 7 8 10 12
72. imensional plane in whole pixel units It is identical to the Point Class but has units of whole pixels intended for use the raster graphics where exactly pixel alignment is needed Constructors Point int16_t x 0 0f intl6 t y 0 0f Creates a new point at x y Point const Point amp source Copy constructor Fields int16 t x This point s x coordinate intl t y This point s y coordinate Methods static float GetHoirzontalDisplacement const Point amp p0 const Point amp pl Gets the horizontal displacement between p0 and p1 static float GetVerticalDisplacement const Pointg p0 const Point amp pl Gets the vertical displacement between p0 and p1 static float GetDisplacement const Point amp p0 const Point pl Gets the displacement between p0 and p1 static float GetAngleRadians const Point amp p0 const Point amp pl Gets the angle from the horizontal in radians for the line connecting p0 and p1 Operators Point amp operator const Point amp source Copy assignment operator bool operator const Point rhs Returns true if this point s coordinates are equal to rhs s coordiantes bool operator const Point rhs Returns true if this point s coordinates are not equal to rhs s coordiantes Comfile Technology MoaTouch User s Manual 96 of 124 MoaTouch User s Manual Point Class Represents a point in a 2 dimensional plane Constructors Point float x 0 0f float y
73. ing other visuals that they may overlap Foreground Layer 2 Foreground Layer 1 Background Layer Composite Buffer TON A At power on the M Display creates a background layer as the default drawing surface Additional foreground layers can be created with the LCD CreateForegroundLayer function The user can draw independently to the background layer or any foreground layer Using the painter s algorithm background layer rendered first foreground layer 1 rendered second foreground layer n rendered last the layers are combined into a single frame buffer the composite buffer Then on every vertical refresh of the LCD any changes to the composite buffer are flushed to the screen The flushing of the composite buffer to the LCD can be controlled with the LCD DisableFlush and LCD EnableFlush functions This can be useful to prevent the M Display from displaying part of a composite visual until the entire visual has been completely drawn It can also improve performance when drawing many visuals as the M Display doesn t have to waste resources updating the LCD multiple times Comfile Technology MoaTouch User s Manual 32 of 124 MoaTouch User s Manual Using Layers to Update Text Using layers is particularly useful when updating text Consider the desire to update text on green background Attempt 1 If one calls LCD FillText function and attempts to update the text with a second call to LCD FillText the th
74. ing the MoaTouch DFU Driver if you set dipdwitch 2 to the ON position and power on the MoaTouch you will see the MoaTouch appear as STM Device in DFU Mode in Windows Device Manager as e Universal Serial Bus controllers STM Device in DFU Mode Now using the MoaTouch Control Panel you will be able to upload programs from the host PC to the MoaTouch Comfile Technology MoaTouch User s Manual 11 of 124 MoaTouch User s Manual MoaTouch Control Panel The MoaTouch Control Panel is a program that gives the user the ability to upload programs to the MoaTouch and monitor a program s execution Using it in concert with your software development environment will make programming the MoaTouch quite convenient The MoaTouch Control Panel can be run from the Windows Start Menu under Comfile Tools This program requires the Net Framework 4 0 client profile which can be downloaded from Microsoft ll PR MoaTouch Control Panel When executed the following window will appear r Always show this window Bj MoaTouch Contr visually on top of other windows Reset the MoaTouch See explanation below Control the console window See explanation below Upload programs to the MoaTouch See explanation below MoaTouch s status Disconnected if the MoaTouch is not connected to the host PC DFU if the MoaTouch is connected in DFU mode COMxx Open if the MoaTouch is connected as a virtual serial port c
75. l file or folder Methods std string GetName const Gets the file folder name size_t GetSize const Returns the size of the file in bytes bool IsFile const Returns true if this is a file bool IsFolder const Return true if this is a folder Example Please see the SDCard Class Example for a demonstration using this class Comfile Technology MoaTouch User s Manual 62 of 124 MoaTouch User s Manual FiniteStreamReader Class The is an abstract class to provide a uniform interface for accessing streams of data It is implemented by the File Class and the MemoryStream Class Methods virtual size t GetCurrentPosition 0 Reports the current position in the stream virtual size t GetSize const 0 Reports the total number of bytes in the stream size_t Read void const buffer const size_t numOfBytes Read numOf Bytes from the current position in the stream and store the data read in buffer This method will also advance the current position in the stream by numOfBytes virtual void Seek const size t position 0 Moves to the given position in the stream Comfile Technology MoaTouch User s Manual 63 of 124 MoaTouch User s Manual ForegroundLayer Class This class is used to create independent areas of the screen and combine them using the painter s algorithm ForegroundLayer s can be created with the LCD CreateForegroundLayer method It inherits from the Layer Class Miscellaneous Metho
76. l if when the timer s interval is reached Example include lt MoaTouch h gt using namespace MoaTouch void OnTimerTick digitalOutputs 0 Toggle Toggle Digital Output 0 when the timer ticks int main timer SetInterval 1000 Interrupt every 1 millisecond timer SetOnTick OnTimerTick Call OnTimerTick on every interrupt timer Enablelnterrupt Begin interrupting on every tick run forever while true return 0 lt See Digital Output 0 s waveform on the next page gt Comfile Technology MoaTouch User s Manual 118 of 124 MoaTouch User s Manual The following shows the output of Digital Input O on an oscilloscope M Pos 80 00 Us TAI i tot Ay Fa a 24 Jun 14 15 45 3999 911Hz Comfile Technology MoaTouch User s Manual 119 of 124 MoaTouch User s Manual Touch Class This class provides access to the MoaTouch s touch screen It is implemented as a singleton class whose instance can be accessed via the touch identifier Methods void Calibrate std function lt void Point point gt drawPoint Calibrates the touch screen drawPoint is a user supplied callback function for displaying the point for the user to touch on the screen n td function lt void Point point gt GetOnMove const O ets the function to call when the user moves drags while touching 10 td function lt void Point point gt GetOnRelease const ets the function to call when a touch
77. lid void SetMonth uint8 t value Sets the month component 1 12 range error exception is thrown if value is invalid void SetSeconds uint8 t value Sets the seconds component 0 59 range error exception is thrown if value is invalid void SetYear uint16_t value Sets the year component 1900 2099 range error exception is thrown if value is invalid Operators bool operator const DateTime amp rhs Returns true if this value is equal to rhs Comfile Technology MoaTouch User s Manual 48 of 124 MoaTouch User s Manual bool operator const DateTime amp rhs Returns true if this value is not equal to rhs Example include lt MoaTouch h gt include lt string gt using namespace std using namespace MoaTouch Add leading zeros to numbers less than 10 static string PadZeros uint8 t value return value lt 10 0 ToString value ToString value int main lcd SetBacklightBrightness 255 Start Off with a blank sereen lcd EnableFlush led Clear while 1cd HasChanges keep track of previous value so we only update when the value changes DateTime previousValue while true Get the current date and time DateTime currentValue rtc Get Don t update screen unless time has changed if currentValue previousValue Disable updating changes on the screen Helps avoid flickering lcd DisableFlush Clear the screen led Clear rem
78. loses the given open file Throws a std runtime error on failure void Create const std stringg path Creates a new file at the given path If the path ends in a character a folder will be created Throws a std runtime error on failure bool Exists const std stringg path Returns true if a file or folder at the given path exists void GetChildren const std string amp path std vector lt Filelnfo gt s info Gets children of the given folder Throws a std runtime error on failure FileInfo GetInfo const std stringg8 path Gets the information on the given file or folder Throws a std runtime error on failure v td function lt void gt GetOnEjected const ets the function to be called when an SD Card is ejected O 10 td function lt void const std exceptions gt GetOnError const ets the function to be called if there is an error while accessing the SD Card O std function lt void gt GetOnInserted const Gets the function to be called when an SD Card is inserted bool IsInserted const Returns true if an SD Card is inserted bool IsMounted const Returns true if the file system is mounted void Mount Mount the file system void Move const std strings existingPath const std stringg newPath Moves a file from existingPath to newPath Throws a std runtime error on failure File Open const std string amp path Opens a file on the SD Card Throws
79. lse void Off bool off true Sets the current output state to logic low off true or logic high off false void High bool high true Sets the current output state to logic high high true or logic low high false void Low bool low true Sets the current output state to logic low low true or logic high low false void Toggle Toggles the current output state Comfile Technology MoaTouch User s Manual 53 of 124 MoaTouch User s Manual DigitalOutputs Class This class simply provides indexers for retrieving the DigitalOutput Class instances Methods uint32 t GetState const Returns the state of all 32 outputs The least significant bit is bit ExDigitalOutput Pin 00 void SetState uint32 t value Sets the state of all 32 outputs The least significant bit is bit ExDigitalOutput Pin 00 Operators DigitalOutput amp operator DigitalOutput Pin pin const Returns the DigitalOutput Class instance assigned to the given pin DigitalOutput amp operator int index const Returns the DigitalOutput Class instance at the given index Will throw a std out_of range exception of index is invalid Comfile Technology MoaTouch User s Manual 54 of 124 MoaTouch User s Manual Ethernet Class This class is used to configure the MoaTouch s Ethernet port This class is implemented as a singleton and can be accesses using the ethernet identifier Use the Socket Class to perform
80. m Files x86 ComfileTools MoaTouch Tools GNU Tools for ARM Embedded Processors oa Auto detect NOTE All programs must exist either in the bin sub directory of this path or in any of the Additional paths Program Files additional Paths C compiler arm none eabi gcc exe C compiler arm none eabi g exe Linker for dynamic libs arm none eabi g exe Linker for static libs arm none eabi ar exe Debugger GDB CDB debugger Default v Resource compiler Make program make exe The compiler is now configured Click the OK button to finish OK Cancel Comfile Technology MoaTouch User s Manual 18 of 124 MoaTouch User s Manual Creating a New Project This procedure will show how to make a simple Hello World project for the MoaTouch in Code Blocks From the Code Blocks menu select File gt New gt Project File Edit View Search Project Build Debug Fortran wxSmith Tools Tools Plugins D Empty file Ctri Shift N El B Open Ctrl O Class Open with hex editor Project Open default workspace Build target Recent projects File Recent files gt g Custom Import project gt From template amp Save file Ctrl S Nassi Shneiderman diagram A Save file a and select Empty project and click the Go button New from template E Projects Category lt All categories gt y Build targets Fies Gy 9 4 Y y User tem
81. mestamp World World Program Upload E File C MoaTouch Hello WordWelk lorldt World Browse Upload World World World World World World World World World COM15 Open Comfile Technology MoaTouch User s Manual 13 of 124 MoaTouch User s Manual Developing Software for the MoaTouch The MoaTouch Tools installation utility will install the GNU ARM Embedded Toolchain to the Installation Folder ComfileTools MoaTouch Tools GNU Tools for ARM Embedded Processors folder This is a variant of the GNU toolchain and includes the GCC compiler linker and much more Detailed documentation on this toolchain can be found in the share folder In this section we will describe how to use this toolchain to program the MoaTouch The GNU ARM Embedded Toolchain can be used with many text editors IDEs and other tools for software development Software developers are quite particular about their tools so we will not advocate one specific editor or IDE Rather we will show the general procedure one would use to compile software with this toolchain and leave it to the reader to take this information and configure their editor IDE or other tools as they prefer We will use a simple text editor to edit the code the Windows command console to invoke the GNU toolchain and the MoaTouch Control Panel to upload our program to the MoaTouch We will create a simple Hello World program to illustrate this procedure Editing the Sour
82. n it creates an 800x480x16 bits 768KB background layer and an 800x480x16 bits 768KB composition layer These layers only need 16 bits per pixel because they are opaque layers That leaves approximately 2 2 5MB of memory for any foreground layers cached fonts and other loadable content Foreground layers will reside on top of the background layer and will therefore need an additional byte for the alpha transparency component This byte in addition to the 16 bits required for the RGB components results in for a total of 24 bits per pixel So as an example an 800x480 foreground layer will need 800x480x24 bits 1 152KB of memory As can be seen layers can potentially consume a lot of memory So be sure to create layers sparingly and keep them to as small an area as possible to avoid running out of memory Comfile Technology MoaTouch User s Manual 34 of 124 MoaTouch User s Manual Calibrating the Touch Screen User s may wish to integrate touch screen calibration into their application in a variety of ways so we have created a special Touch Calibrate method to accommodate this The Touch Calibrate function takes a single parameter a function to draw the point on the screen where the user should touch The Touch Calibration function will call this function 5 times to complete a 5 point calibration Between each point the MoaTouch will wait for the user to touch the screen The MoaTouch will take an average of the valu
83. ne ends abruptly right a the coordinate of the end point Round End point is given a rounded cap that may extend beyond the coordinate of the end point Square End point is given a square cap that may extend beyond the coordinate of the end point Example This example shows the appearance of each kind of end cap include lt MoaTouch h gt using namespace MoaTouch int main lcd SetBacklightBrightness 255 start off with a blank screen 1cd EnableFlush 1lcd Clear while 1cd HasChanges draw 10 pixel wide horizontal line with Butt cap SolidBrush white 0xFF OxFF OxFF Stroke horizontalStroke 10 0f LineCap Butt ledeDrawlane OOO OOO 1200 0f OOO horazontalStroke white draw 10 pixel wide horizontal line with Round cap horizontalStroke SetCap LineCap Round Ted Diceywiinhine GOO O LSO Oe 200 0 ISO Wiel horrzontalStroke wise A draw 10 pixel wide horizontal line with Square cap horizontalStroke SetCap LineCap Square led DrawLine 100 0f 200 0 7 200 0 20001 hortizontalStroke white draw l pixel wide red vertical lines showing the line s end point coordinates SolidBrush red 0OXFE 0x00 0x007 Stroke verticalStroke 1 0f Lled Dreta CUADO 0 VO oi LO 0E 21008 verticalStroke red Lal DrawLine 1200 0f 0 0 2000 2110 0561 verticaLStroke red run forever while true return 0 Comfile Techn
84. ner of this area uintl6 t GetHeight const Gets the height of this area Area GetIntersection const Area amp area const Returns an area that is the intersection of the given area and this area intl6 t GetLeft const Gets the left most x coordinate of this area int16_t GetRight const Gets the right most x coordinate of this area int16_t GetTop const Gets the top most y coordinate of this area Point GetTopLeft const Gets the point that is the top left corner of this area Point GetTopRight const Gets the point that is the top right corner of this area uintl6 t GetWidth const Gets the width of this area bool Intersects const Point amp point const Returns true if the given point intersects this area bool Intersects const Area amp area const Returns true if the given area and this area intersect one another bool IsOffBottomBound float value const Returns true if the given coordinate lies below this area bool IsOffBottomRightBound const Point amp point const Returns true if the given point is either to the right of this area below this area or both bool IsOffLeftBound float value const Comfile Technology MoaTouch User s Manual 94 of 124 MoaTouch User s Manual Returns true if the given coordinate lies to the left of this area bool IsOffRightBound intl6 t value const Returns true if the given coordinate lies to the right of this area bool IsOffTopBound int1l6 t valu
85. ns Output dir bin Releasel Objects output dir objlReleasel lt Back Finish Cancel Comfile Technology MoaTouch User s Manual 20 of 124 MoaTouch User s Manual Adding Source Code Files to the Project Now we need to add code files to the project From the Code Blocks menu select File gt New gt File File Edit View Search Project Build Debug Fortran wxSmith Tools Tools Plugins C ae cursen El B Open Ctrl O Class Open with hex editor Project Open default workspace Build target j Recent me File Recent files gt Custom Import project y From template B Save fil Ctrl S Nassi Shneiderman diagram Select C C source and click the Go button Category lt All categories gt y Go New from template E P C C header Empty fle Fortran source a a P Then select C and click the Next button Comfile Technology C FILE Please select the language for the file C C source E Please make a selection C lt Back Next gt Cancel MoaTouch User s Manual 21 of 124 MoaTouch User s Manual Enter the path to the file main cpp and click the Finish button C C source El E Please enter the file s location and name and aS C C FILE whether to add it to the active project Filename with full path sers ThisUser DesktopHelloWorldmain cppl
86. nt p1 static Path Curve const Point from const Pointg control const Point to Create a bezier curve from point from to point to with control point control static Path Curve const Point from const Pointg control0 const Point controll const Point amp to Create a bezier curve from point from to point to with control points control0 and controll static Path Arc const Point amp center float horizontalRadius float verticalRadius float startAngle float sweep Create an elliptical arc starting at startAngle traveling sweep degrees static Path Rectangle const Areas area float cornerRadius 0 Create a rectangle or rounded rectangle encompassing the given area with uniform corner radii cornerRadius static Path Rectangle const Area amp area float topLeftConerRadius float topRightConerRadius float bottomLeftConerRadius float bottomRightConerRadius Create a rounded rectangle encompassing the given area with nonuniform corner radii static Path Circle const Pointg center float radius Create a circle with the given center and radius static Path Ellipse const Point amp center float horizontalRadius float verticalRadius Create a ellipse static Path Text const Point point const FiniteStreamReaderg font const std u32stringsg text float size float angle 0 0f Create a path from the given text using the given font static Path Text con
87. ntBrush Items Solid The brush is of type SolidBrush LinearGradient The brush is of type LinearGradientBrush RadialGradient The brush is of type RadialGradientBrush Comfile Technology MoaTouch User s Manual 43 of 124 MoaTouch User s Manual Color Class Represents a 24 bit color 8 bit alpha 5 bit red 6 bit green 5 bit blue Constructors Color uint8_t red 0x00 uint8_t green 0x00 uint8 t blue 0x00 uint8 t alpha OxFF Defaults to opaque black Color const Color amp color Copy constructor Methods void AlphaBlend const Color565 amp fgColor uint8 t alpha Blends the foreground color fgColor with this color alpha is the opacity of fgColor uint8_t GetAlpha const Gets the alpha color component uint8 t GetBlue const Gets the b ue color component uint8 t GetGreen const Gets the green color component uint8 t GetRed const Gets the red color component bool IsOpaque const Returns true if the color is opaque alpha OxFF bool IsTransparent const Returns true if the color is transparent alpha 0x00 Color Lighten const Color565 amp color float factor Lightens this color by the given factor and returns the result as a new color void SetAlpha const uint8 t value Sets the alpha color component void SetGreen const uint8 t value Sets the green color component void SetBlue const uint8 t value Sets the blue color componen
88. nual Parity Enumeration This enumeration is used with the SerialPort Class to specify it s parity setting Note that if using Parity Odd or Parity Even the SerialPort s DataBits must be DataBits Bits9 to accommodate the parity bit Items None 0 No parity Odd 1 Odd parity Even 2 Even parity Example Please see the SerialPort Class Example for a demonstration of this enumeration Comfile Technology MoaTouch User s Manual 93 of 124 MoaTouch User s Manual PixelArea Class A 2 dimensional rectangular area in whole pixel units It is identical to the Area Class but has units of whole pixels intended for use the raster graphics where exactly pixel alignment is needed Constructors Area Creates a area at 0 0 with a width and height of 0 Area int16_t x0 intl6 t yO int16 t x1 intl6 t yl Creates a rectangular area from four coordinates identifying the points at opposite corners on a diagonal Area Point p0 Point pl Creates a rectangular area from two points at opposite corners on a diagonal Area Point topLeft uintl6 t width uintl6 t height Creates a rectangular area with the top left corner at topLeft with a width of width and a height of height Methods intl6 t GetBottom const Gets the bottom most y coordinate of this area Point GetBottomLeft const Gets the point that is the bottom left corner of this area Point GetBottomRight const Gets the point that is the bottom right cor
89. oat radius const Color amp outerColor Instantiates a new instance of this class with the given center GradientStop radius and outer Color RadialGradientBrush const RadialGradientBrush amp source Copy constructor Methods GradientStop GetCenter const Returns the center GradientStop void SetCenter const GradientStop amp value Sets the center GradientStop float GetRadius const Gets the radius from the center GradientStop to the outer color void SetRadius float value Sets the radius from the center GradientStop to the outer color Color GetOuterColor const Gets the outermost color that the gradient should blend to as it gets further from the center void SetOuterColor const Colors value Sets the outermost color that the gradient should blend to as it gets further from the center BrushType GetType const Returns BrushType RadialGradient to identify this brush as a radial gradient Operators RadialGradientBrush amp operator const RadialGradientBrushg source Copy assignment operator Example This example will display a rounded rectangle in a gray to blue radial gradient from the top left corner to the bottom right corner include lt MoaTouch h gt using namespace MoaTouch int main start off with a blank screen lcd SetBacklightBrightness 255 icd EnableFlush led Clear while lcd HasChanges Create a gray to blue radial gradient brush CAME ES Ox OROZ
90. of the MoaTouch library uint32_t GetHardwareMajorVersion const Gets the major version number of the MoaTouch hardware uint32_t GetHardwareMinorVersion const Gets the minor version number of the MoaTouch hardware Comfile Technology MoaTouch User s Manual 117 of 124 MoaTouch User s Manual Timer Class This class provides a periodic timer to interrupt a program a given interval The timer is implemented as a singleton accessible via the timer identifier The timer s resolution is 1 microsecond so users can specify interrupt intervals with great precision However setting the interval to 1 microsecond will cause an interrupt storm where the program will be spending so much time servicing the interrupt it won t have the resources to do anything else Therefore it is recommended to keep the interval greater than 100 microseconds Methods Timer Channel GetChannel Gets the channel identifying this timer instance uint16_t GetInterval const Gets the time between ticks in microseconds void SetInterval uint32 t value Set the time between ticks in microseconds void EnableInterrupt bool enable true Enable the timer s interrupt void DisableInterrupt bool disable true Disables the timer s interrupt std function lt void gt GetOnTick const Gets the function to call if when the timer s interval is reached void SetOnTick std function lt void gt value Sets the function to cal
91. ology MoaTouch User s Manual 79 of 124 LineJoin Enumeration This enumeration is used with the Stroke Class to define the appearance of two adjoining lines in a Path Items Miter Line joint is drawn with a sharp corner Round Line joint is drawn with a rounded corner Bevel Line joint is drawn with a beveled corner Example This example shows the appearance of each kind of end cap include lt MoaTouch h gt using namespace MoaTouch aliada Comfile main start off with a blank screen led SetBacklight Brightness 255 lcd EnableFlush led Clear y while lcd HasChanges Draw line with a rounded joint SolidBrush white OxFF OxFF OxF Stroke stroke 10 0f LineCap But Path path path MoveTo 100 0f 100 0f Pathe la mneios ies OR OO pathi Nero 200m0 100i s lcd DrawPath path stroke white Draw line with a mitered joint stroke SetJoin LineJoin Miter path Clear path MoveTo 250 0f 100 0f Pathe amo ESOO 0 OE path LineTo 3580 0 L00 0 1lcd DrawPath path stroke white Draw line with a beveled joint stroke SetJoin LineJoin Bevel path Clear path MoveTo 400 0f 100 0f path LineTo 450 0f 50 0f path LineTo 500 0f 100 0f lcd DrawPath path stroke white run forever while true return 0 Technology Fh t LineJoin Round T 7 7 MoaTouch User s Manual MoaTouch User s Manual 80 of 124 MoaTo
92. om Clear area of the screen for plotting new point ca Crest enzo WO 2 ABO Draw line between previous point and current point Point previousPoint cursor 1 0f previousValue Point currentPoint cursor currentValue lcd DrawLine previousPoint currentPoint linel green Draw cursor Ied DrawLine ecursor ap Ose Wo Oieh Toursor t Oi 479 0810 Linel asias A Wait for all changes to be drawn while lcd HasChanges return 0 Comfile Technology MoaTouch User s Manual 36 of 124 MoaTouch User s Manual Comfile Technology MoaTouch User s Manual 37 of 124 MoaTouch User s Manual AnalogInputs Class This class simply provides indexers for retrieving the AnalogInput Class instances Operators AnalogInput amp operator AnalogInput Pin pin const Returns the AnalogInput Class instance assigned to the given pin Analoginput amp operator int index const Returns the AnalogInput Class instance at the given index Will throw a std out_of_range exception of index is invalid See the AnalogInput Class Example for a demonstration of this operator Comfile Technology MoaTouch User s Manual 38 of 124 MoaTouch User s Manual Area Class A 2 dimensional rectangular area Constructors Area Creates a area at 0 0 with a width and height of 0 Area float x0 float y0 float x1 float yl Creates a rectangular area from four coordinates identifying the points at
93. onsole Console Window When ta program begins executing the MoaTouch will appear to the host PC as a virtual serial port If the program sends a message to either standard out or standard error those messages will appear in the Console Window gt Show Show or hide the Console Window gt Always on Top Always display the Console Window on top of all other windows gt Clear Clear all text in the Console Window gt Timestamp Display a timestamp next to each line displayed in the console window This can be useful for logging Program Upload When dipswitch 2 is in the off position and the MoaTouch is first powered on it will appear to the host PC as a DFU device In this mode a program can be uploaded from to the MoaTouch After uploading a program the MoaTouch will immediately begin executing that program despite the status of dipswitch 2 gt File Path to the program s executable hex to be uploaded to the MoaTouch gt Browse Use windows explorer to locate the program s executable file gt Upload Upload the program s executable to the MoaTouch and begin executing it The Reset Button Pressing the Reset button will tell the MoaTouch to perform a software reset If the MoaTouch is in DFU mode it will exit DFU mode and attempt execution of the program If the MoaTouch is executing a program and dipswitch 2 is in the ON position the MoaTouch will re enter DFU mode If the MoaTouch is
94. onst Brush amp brush Draw a bezier curve from point from to point to with control point control using the given stroke and brush Please see Example Lines Curves for a demonstration of this method void DrawCurve const Pointg from const Pointg control0 const Point amp controll const Point amp to const Stroke amp stroke const Brush amp brush Draw a bezier curve from point from to point to with control points control0 and controll using the given stroke and brush void DrawPath const Path amp path const Stroke amp stroke const Brush amp brush Draw the given path using the given stroke and brush See the Path Class Pie Section Example and Curve Example and for a demonstration of this method void FillPath const Path amp path const Brush amp brush Fill the given path using the given brush See the Path Class Pie Section Example and Curve Example and for a demonstration of this method Area MeasurePath const Path amp path const Stroke amp stroke Get the encompassing bounding box of the path if it were drawn with the given stroke Comfile Technology MoaTouch User s Manual 68 of 124 MoaTouch User s Manual Text Methods void DrawText const Point amp baselineOrigin FiniteStreamReaderg font const std u32string amp text float size const Strokes stroke const Brush brush void DrawText const Point amp baselineOrigin FiniteStreamReaderg font const std u32string amp text flo
95. opposite corners on a diagonal Area Point p0 Point pl Creates a rectangular area from two points at opposite corners on a diagonal Area Point topLeft float width float height Creates a rectangular area with the top left corner at topLeft with a width of width and a height of height Methods float GetBottom const Gets the bottom most y coordinate of this area Point GetBottomLeft const Gets the point that is the bottom left corner of this area Point GetBottomRight const Gets the point that is the bottom right corner of this area float GetHeight const Gets the height of this area Area GetIntersection const Areas area const Returns an area that is the intersection of the given area and this area float GetLeft const Gets the left most x coordinate of this area float GetRight const Gets the right most x coordinate of this area float GetTop const Gets the top most y coordinate of this area Point GetTopLeft const Gets the point that is the top left corner of this area Point GetTopRight const Gets the point that is the top right corner of this area float GetWidth const Gets the width of this area bool Intersects const Point amp point const Returns true if the given point intersects this area bool Intersects const Areas area const Returns true if the given area and this area intersect one another bool IsOffBottomBound float value const Re
96. orld World Comfile Technology o B V Always On Top Set Date and Time Reset Console Window V Show Always On Top Clear Timestamp Program Upload File C MoaTouch Hello Worid WHelk Browse Upload COMIS5 Open MoaTouch User s Manual 16 of 124 MoaTouch User s Manual Configuring a Software Integrated Development Environment IDE With the information in the previous section one can configure one of the many C C IDEs available To illustrate this procedure we will show how to configure Code Blocks a free and open source IDE available for download from http www codeblocks org Although this procedure is specific to Code Blocks readers should be able to adapt this procedure to just about any development environment Configuring the Compiler Code Blocks does not know about the MoaTouch so we must teach it From the Code Blocks menu choose Settings gt Compiler to open the Global Compiler Settings window Compiler settings amp Global compiler settings Selected compiler A GNU GCC Compiler for ARM v Set as default Copy Rename Delete Reset defaults Global compiler settings Compiler settings Linker settings Search directories Toolchain executables Custom variables Build options Policy ed kl Compiler Flags Other options defines Categories lt All categories gt v Profiler settings Produce debugging symbols g A Prof
97. ormat uses the same format specifiers as printf void Print const std stringe s Prints a string format uses the same format specifiers as printf void PrintLine const char format nullptr Prints formatted data appended with a new line format uses the same format specifiers as printf void PrintLine const std string amp s Prints string appended with a new line format uses the same format specifiers as printf std string GetNewLine const Gets a string to use for new lines void SetNewLine const string amp value u8 r n Sets the string to use for new lines Example include lt MoaTouch h gt using namespace MoaTouch int main while true console PrintLine Hello World Delay_ms 500 return 0 53 Yorn EAI EOE Open a 8 World World World World v Always On Top World World _Set Date and Time Reset World World World World Clear Timestamp World World Program Upload World File C MoaTouch Hello World Helk World World Browse Upload World E g World World World World World World World World Console Window V Show Always On Top COM15 Open Comfile Technology MoaTouch User s Manual 46 of 124 MoaTouch User s Manual DataBits Enumeration This enumeration is used with the SerialPort Class to specify the number of data bits i e word length Items Bits8 8 8 bit word length Bits9 9 9 bit word l
98. plates ARM Project AVR Project area Console plugin application D application Link por 7 o FLTK project Fortran DLL Fortran Fortran library application GLEW GLUT a Bs View as Gu Gu 0 8 Large icons GLFW project GLUT project GTK project Irrlicht project y Olit TIP Try right dicking an item 1 Select a wizard type first on the left 2 Select a specific wizard from the main window filter by categories if needed 3 Press Go Enter the project information and click the Next button Empty project El E l Please select the folder where you want the new project w Console to be created as well as its title Project title HelloWorld Folder to create project in C Users ThisUser Desktop Project filename HelloWorld cbp Resulting filename C UsersThisUser Desktop HelloWorld HelloWorld cbp lt a wet Cons Comfile Technology MoaTouch User s Manual 19 of 124 MoaTouch User s Manual Select the MoaTouch Compiler that was configured in the previous section and create a Release configuration Then click the Finish button Empty project El Please select the compiler to use and which configurations you want enabled in your project Compiler Moat ouch Comer y E Console m Debug options Output dir bin Debug Objects output dir obj Debug Create Release configuration Release Release optio
99. rawLine 2 0f 2 0 12 Oi 2 0f stroke White One might expect this to draw a bright white horizontal line 10 0 pixels long and exactly 1 0 pixel thick However the line actually appears blurred Zoomed in one can see the line is actually 2 0 pixels thick and light gray in color as shown below Comfile Technology MoaTouch User s Manual 25 of 124 MoaTouch User s Manual 0 0 To understand why this is one must understand that pixels are not dimensionless rather they have a width and height The most common displays have a pixel array of 72 DPI dots per inch meaning each pixel is approximately 0 013 inches square pixels aren t actually square but it helps this explanation to think of them as square 0 0 m Ml Coverage 50 Coverage 50 12 0 25 To draw a 1 0 pixel thick horizontal line from 2 0 2 0 to 12 0 2 0 that really means drawing a 10 0 pixel wide 1 0 pixel tall rectangle centered on the line between 2 0 2 0 and 12 0 2 0 Therefore the rectangle s top left corner is 2 0 1 5 and bottom right corner is 12 0 2 5 This is illustrated on the graph below The outline of the actual line is shows in red NOTE The ends of the line are clipped exactly at the x coordinates due to the Butt end cap One can see that the line partially covers the pixels in rows 2 and 3 That is why the line appears to be two pixels wide The pixels in row 2 and 3 are each only half covered i e the pixel cov
100. rightness 255 led EnableFlush led CU lear is while lcd HasChanges display an opaque green rectangle SolidBrush opaqueGreen 0x00 OxFF 0x00 led FillRectangle 50 0f 50 0f 100 0f 100 0f opaqueGreen display a partially transparent fuchsia rectangle SolidBrush partiallyTransparentFuchsia OxFF 0x00 OxFF 0xA9 lcd FillRectangle 100 0f 100 0f 100 0f 100 0f partiallyTransparentFuchsia while true run forever return 0 Comfile Technology MoaTouch User s Manual 111 of 124 MoaTouch User s Manual StopBits Enumeration This enumeration is used with the SerialPort Class to specify the number of stop bits in the SerialPort s settings Items Bits0_5 0 5 bits Bits1_0 1 0 bit Bits1 5 1 5 bits Bits2 0 2 0 bits Example Please see the SerialPort Class Example for a demonstration of this enumeration Comfile Technology MoaTouch User s Manual 112 of 124 MoaTouch User s Manual Stopwatch Class This class can be used to measure time with microsecond precision It can also be used to insert time delays in a program It is implemented as a counter which rolls over every 50 seconds so it cannot be used to measure time beyond that To measure longer times use the RTC Class Constructors Stopwatch Default constructor Stopwatch const Stopwatchg source Copy constructor Methods static void DelaySeconds float seconds MoaTouch Delay s float seconds
101. rs in code gt Only ASCII characters are supported in file and folder names Ethernet Ethernet port for connecting the MoaTouch to a network It can be programmed using the Ethernet and Socket classes Reset Switch Push this switch to perform a hard reset cpm Comfile Technology MoaTouch User s Manual 10 of 124 MoaTouch User s Manual Software Installation To begin utilizing the MoaTouch a few PC tools are required gt MoaTouch Virtual Serial Port Console Driver gt MoaTouch Control Panel utility program gt MoaTouch Device Firmware Upgrade DFU Driver gt GNU ARM Embedded Toolchain These are all distributed in a single package called MoaTouch Tools available for download from Comfilte Technology s website www ComfileTech com Simply run the install utility and follow the on screen instructions to install this software on the host PC a em MoaTou Welcome to the MoaTouch Tools Setup Wizard This will install MoaTouch Tools version 1 0 0 0 on your computer Itis recommended that you dose all other applications before continuing Click Next to continue or Cancel to exit Setup Installing the MoaTouch DFU Driver After running the MoaTouch Tools installation utility you ll need to install the MoaTouch DFU driver so you can upload programs the the MoaTouch You can find a link to the driver s installation utility in Windows Start Menu under Comfile Tools After install
102. s de mcpu cortex m4 nfpu fpv4 sp d16 mfloat abi softfp fsingle precision constant ffunction sections fdata sections Comfile Technology MoaTouch User s Manual 17 of 124 MoaTouch User s Manual Go to the Linker Settings tab and enter the following options j Search directories Toolchain executables Custom variables Build options Other settings Link libraries Other linker options mthumb mepu cortex m4 mipu fpv4 sp d16 mfloat abi softfp WI gc sections WI whole archive dMoaTouch a Wl no whole archive lt WI T C Program Files x86 ComfileTools MoaTouch Tools inker scriptMoaTouch Id The last option should be the path to the linker script in the MoaTouch Tools installation folder Then go to the Search directories tab and enter the MoaTouch Tools include folder and library folder Toolchain executables Custom variables Build options C Program Files x86 ComfileTools MoaTouch Toolslindude Compiler settings Linker settings Search directories Toolchain executables Custom variables Build options gt C Program Files x86 ComfileTools MoaTouch Tools Yib Finally go t the Toolchain executables tab and enter the following Compiler settings Linker settings Search directories Custom variables Build options Other settings Compiler s installation directory C Progra
103. s method before calling this method slaveAddress The Modbus slave address of the device to query startAddress The Modbus address of the first coil to write value The value to write to the coil void ForceMultipleCoils uint8 t slaveAddress uintl6 t startAddress const std vector lt bool gt s values Performs a Write Mutiple Coils function code 15 query This function will throw a std runtime_error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method slaveAddress The Modbus slave address of the device to query startAddress The Modbus start address of the first coil to write s values The collection of sequential values to write void PresetSingleRegister uint8 t slaveAddress uintl6 t startAddress uintl6 t value Performs a Write Single Register function code 6 query This function will throw a std runtime_error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method slaveAddress The Modbus slave address of the device to query startAddress The Modbus address of the register to write E value The value to write to the register void PresetMultipleRegisters uint8 t slaveAddress uint16_t startAddress const std vector lt uintl6 t gt amp values Performs a Write Multiple Registers function code 16 query This function will throw
104. s set in the Open function size_t GetTxCapacity const Gets the transmit buffer capacity for this serial port as set in the Open function void Open size_t txCapacity size_t rxCapacity Opens this serial port allocating memory for the transmit and receive buffers void Close Close this serial port deallocating the transmit and receive buffers bool IsOpen const Returns true if the port is opened size_t GetRxCount const Gets the number of bytes currently in the receive buffer size_t GetTxCount const Gets the number of bytes currently in the transmit buffer Comfile Technology MoaTouch User s Manual 102 of 124 MoaTouch User s Manual size_t Write const void buffer const size t size Writes size bytes from buffer to the transmit buffer Returns the number of bytes written to the transmit buffer size_t WriteByte uint8 t value Writes a single byte to the transmit buffer Returns the number of bytes written to the transmit buffer size_t Read void buffer const size t size Reads size bytes from the receive buffer to buffer Returns the number of bytes copied int ReadByte Reads a single byte from the receive buffer Returns the byte read from the receive buffer or a negative number if the receive buffer is empty void Print const char Cc Writes a single char to the transmit buffer void Print const char c Writes a null terminated string to the transmit buffer void Print const
105. ssdasGedeccmaaatamenaaaaesipeeena is ty Seceenandagsd ibeasacaanadedihenhiqaceamanasaanadepews onace sates 45 Console Classis A ie 46 Comfile Technology MoaTouch User s Manual 2 of 124 MoaTouch User s Manual Mea Az 46 A Wa bebtaanens AE diate geesenietesididedeaaietiamiannaneces 46 DataBits Enumerar alada irc 47 A phiuanaddeciaranewandtavansiaanediaeeMassAenaresraGGepanuediiedadnidet E 47 EXP ir iia Peale diet 47 Date Time SS ita ea 48 CONSTRUCTOR a a Se laaabiihes EA wesaaia sane biia Matedatcatecaiecteded dataanoiseanaaduan ame sae tes ones 48 Mer A A A AEEA EEEREN 48 OMEGALOMS iria REE Ea A E OA AOS da naa EE AI Aa P een 48 S A 49 Delay FUNCTIONS 0d IO PR aA ni NE AEA EANN AEEA RAER DAA eeeaveeuene ds 50 PGI CaM UE CAS ii sais 51 Digitalin puts Pin EAU EAS 51 Methods ov iwessseitvevscndsendensadeesivnieseccceadsduancucasncn a 51 DigitallnpuUts ClaSS aii e rin 52 OPEFALONS entra AA asii 52 DigrtalQUtpULCASS in dd A A A la 53 Digit lOutput Pi ENUM i oes siade irinin AETERNE 53 Met cias idad 53 Digit QUEDE AA a A A iS 54 Method e cmoenscexessaicanantemsacsecwueceaad sede tcmantaansamatnaaiane rece tarten sine seaeenanc caantke edad A A APEE 54 MN A RaR 54 Ethernet Class A iii n 55 ME E 55 A A T T E T 55 EXDigitaANMpUE Cli SS A e 56 ExDigitallnput i PIE EE E E E E oS 56 Methode rasis hnn aa eaa O 56 EXDIGIAMMPUTS CIA Ssns ienien aana N oa 57 M
106. st Pointg point const FiniteStreamReaderg font const std stringg text float size float angle 0 0f Create a path from the given text using the given font Constructors Path Create an empty path Comfile Technology MoaTouch User s Manual 89 of 124 MoaTouch User s Manual Path const Path amp source Copy constructor Methods void Clear Clear the path removing all vertices void MoveTo const Point amp to Move to point to to begin drawing See Example Pie Section Example Curve for a demonstration void LineTo const Pointg to Draw a line form the current point to the point to This method can be used to make polylines See Example Pie Section for a demonstration void CurveTo const Pointe control const Pointe to Draw a bezier curve from the current point to point to with control point control void CurveTo const Point amp control0 const Point amp controll const Pointg to Draw a bezier curve from the current point to point to with control points contro10 and controll See Example Curve for a demonstration void ArcTo float horizontalRadius float verticalRadius float rotationAngle const bool largeArc const bool sweep const Point to Draw an elliptical arc from the current point to point to See Example Pie Section for a demonstration The following illustrates the affect of the largeArc and sweep arguments jp A PO 5 arc end Arc end E arc end largeArc
107. start address of the first input to read count The number of inputs to read void ReadHoldingRegisters uint8 t slaveAddress uintl6 t startAddress uintl16 _t count Performs a Read Holding Register function code 3 query This function will throw a std runtime error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method slaveAddress The Modbus slave address of the device to query startAddress The Modbus start address of the first register to read G count The number of registers to read Comfile Technology MoaTouch User s Manual 82 of 124 MoaTouch User s Manual void ReadInputRegisters uint8 t slaveAddress uint16_t startAddress uint16_t count Performs a Read Input Register function code 4 query This function will throw a std runtime error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method G slaveAddress The Modbus slave address of the device to query startAddress The Modbus start address of the first register to read count The number of registers to read void ForceSingleCoil uint8 t slaveAddress uintl6 t startAddress bool value Performs a Write Single Coil function code 5 query This function will throw a std runtime_error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatu
108. state m_modbus gt WaitForResponse Let caller know the this LED handled the touch event return isTouched Comfile Technology MoaTouch User s Manual 84 of 124 MoaTouch User s Manual Read the status of the ModPort output via Modbus and update the UI if something has changed void Update Read the status of the ModPort output via Modbus m_modbus gt ReadCoilStatus 1 m_index 1 ModbusRTUMaster Status status m_modbus gt WaitForResponse if status ModbusRTUMaster Status ResponseReceived Get the Modbus response vector lt bool gt response m_modbus gt GetResponse response if the state has changed iv response 0 l m state remember the new state m state response 0 update the UI ESTOS private winte e m index e ales 07 ieee imis im Area m_area The area of the screen where this LED is displayed ModbusRTUMaster m_modbus pointer to the Modbus RTU Master bool m state remember the current state so we know when something has changed Draw the LED on the screen void Render SolidBrush onOffBrush m_state PRECISA OO mm Osc HEE O00 Bright green if the LED is ON Color 0 00 0 50 M0 Dark green if the LED is Off lcd FillRectangle m_area onOffBrush Draw the green part Draw a white border around the LED SolidBrush white OxFF OxFF OxFF Stroke stroke 2 0 LineCap Butt LineJoin Round
109. std runtime error on failure size_t GetSize const Gets the size of the file in bytes size_t Read void const buffer const size_t numOfBytes Read numOfBytes from the current position in the file and store the data read in buffer Throws a std runtime_error on failure Be aware that the MoaTouch s stack memory does not support DMA so buffer must be allocated on the heap with the new operator or malloc This method will also advance the current position in the file by numOfBytes int ReadByte Reads a single byte from the file Returns a negative number on failure void Seek const size t position Moves the file cursor to the given position Throws a std runtime error on failure void Truncate Truncates the file removing its contents but not the file itself Throws a std runtime error on failure size_t Write const void buffer const size_t numOfBytes Reads numOfBytes from buffer and writes the data to the current position in the file Throws a std runtime_error on failure Be aware that the MoaTouch s stack memory does not support DMA so buffer must be allocated on the heap with the new operator or malloc size_t WriteByte uint8 t value Writes a single byte value to the file Returns the number of bytes actually written Example This example will copy the contents of one file into another include lt MoaTouch h gt using namespace MoaTouch int main while sdCard IsInserted
110. std string s Writes a string to the transmit buffer void PrintLine const char c Writes a null terminated string followed by a newline to the transmit buffer void PrintLine const std string s Writes a string followed by a newline to the transmit buffer std string GetNewLine const Gets a string to use for newlines void SetNewLine const std string amp amp value u8 r n Sets the string to use for newlines std function lt void gt GetOnDataReceived const Gets the function that is to be called when data is received from the serial port void SetOnDataReceived std function lt void gt value Sets the function that is to be called when data is received from the serial port std function lt void const SerialError gt GetOnError const Gets the function that is to be called when a serial port error occurs void SetOnError std function lt void const SerialError gt value Sets the function that is to be called when a serial port error occurs Example This example echos data received on serial port channel 2 back to the host int main user serial port channel 2 SerialPort serialPort serialPorts 2 configure the serial port and open it serialPort SetBaudRate 115200 serialPort SetParity Parity None serialPort SetStopBits StopBits Bits1 Comfile Technology MoaTouch User s Manual 103 of 124 MoaTouch User s Manual serialPort SetDataBits DataBits
111. t void SetRed const uint8 t value Sets the red color component Comfile Technology MoaTouch User s Manual 44 of 124 Color565 Class Represents a 16 bit color 5 bit red 6 bit green 5 bit blue Constructors Color uint8_t red 0x00 uint8 t green 0x00 uint8 t blue 0x00 Defaults to black Color const Colors color Copy constructor Methods void AlphaBlend const Color565 amp fgColor uint8 t alpha Blends the foreground color fgColor with this color alpha is the opacity of fgColor uint8 t GetBlue const Gets the blue color component uint8 t GetGreen const Gets the green color component uint8 t GetRed const Gets the red color component Color Lighten const Color565 amp color float factor Lightens this color by the given factor and returns the result as a new color void SetGreen const uint8_t value Sets the green color component void SetBlue const uint8 t value Sets the blue color component void SetRed const uint8 t value Sets the red color component Comfile Technology MoaTouch User s Manual MoaTouch User s Manual 45 of 124 MoaTouch User s Manual Console Class A class used to print messages to the MoaTouch Control Panel s console printf forwards to the Console Print method It is implemented as a singleton class whose instance can be accessed via the console identifier Methods void Print const char format Prints formatted data f
112. te vertical and horizontal lines SolidBrush white 0xFF OxFF OxFF led DrawLine 0 0f 240 0 799202 240208 stroke white lcd DrawLine 400 0f 0 0f 400 0f 479 0 f stroke white Draw a green quadratic bezier curve parabaola SolidBrush green 0x00 OxFF 0x00 ledi Drawcurve OO OO AO 0 OO Or ice O abr Elias green run forever while true return 0 Comfile Technology 74 of 124 MoaTouch User s Manual Example Rectangles include lt MoaTouch h gt using namespace MoaTouch int maini all Wines px thick Stroke stroke 1 0f rectangle with sharp corners SolidBrush cyan 0x00 OxFF OxFF SolidBrush yellow OxFF OxFF 0x00 cde DrawkRectzanuees ral OO Ore eels Oj Ores LS OO O OO SolidBrush green 0x00 OxFF 0x00 filled rectangle with sharp corners SolidBrush transFuchsia OxFF 0x00 OxFF 0x55 lcd FillRectangle 350 0 100 0 100 0 100 0 run forever while true return 0 lecd DrawRectangle 50 0f 100 0f 150 0f 200 0f stroke rounded rectangle with 20 pixel uniform corner radii filled rounded rectangle with 20px uniform corner radii Tedi Mil recreo le SOOO SO 602 LOO MOO Crh 20 0 MoaTouch User s Manual cyan stroke yellow green transFuchsia Comfile Technology MoaTouch User s Manual 75 of 124 MoaTouch User s Manual Example Plottin
113. the last query Timeout 2 Did not receive a response within the given timeout ResponseReceived 3 Response successfully received CRCError 4 Response contained a CRC error Constructors ModbusRTUMaster SerialPort serialPort uint32 t timeoutInMilliseconds Instantiates a new instance of this class over the given serialPort The given serialPort should be opened and configured separately using the SerialPort Class s features timeoutInMilliseconds specifies how long Modbus queries should wait for a response Methods void ReadCoilStatus uint8 t slaveAddress uintl6 t startAddress uint1l6 t count Performs a Modbus Read Coils function code 1 query This function will throw a std runtime_error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method G slaveAddress The Modbus slave address of the device to query startAddress The Modbus start address of the first coil to read count The number of coils to read void ReadInputStatus uint8 t slaveAddress uintl6 t startAddress uint16 _t count Performs a Modbus Read Discreet Input function code 2 query This function will throw a std runtime error if the status is Status WaitingForResponse It is recommended to verify the status with the GetStatus method before calling this method slaveAddress The Modbus slave address of the device to query startAddress The Modbus
114. this class can be retrieved via the digitalInputs int index Or digitalInputs DigitalInput Pin pin indexers DigitalInput Pin Enum An enumeration for identifying an individual digital input channel 10 13 Methods Pin GetPin const Returns the DigitalInput Pin assignment for this instance bool IsHigh const Returns true if the input is a logic high bool IsLow const Returns true if the input is a logic low bool IsOff const Returns true if the input is a logic low bool IsOn const Returns true if the input is a logic high bool IsInterruptEnabled const Returns true if the interrupt for this instance is enabled The interrupt is disabled by default void Enablelnterrupt const bool enable true Enables the interrupt for this instance The interrupt is disabled by default void Disablelnterrupt const bool disable true Disables the interrupt for this instance The interrupt is disabled by default Edge GetInterruptEdge const Gets the edge trigger for this instance s interrupt void SetInterruptEdge const Edge edge Sets the edge trigger for this instance s interrupt std function lt void gt GetOnInterrupt const Gets the function to be called when this instance s interrupt is triggered void SetOnInterrupt std function lt void gt value Sets the function to be called when this instance s interrupt is triggered Comfile Technology MoaTouch User s Manual 51 of 124
115. to a byte array which can be stored permanently stored along with your program in the MoaTouch s flash memory Method 2 Load the font into memory at runtime as shown below Open the font file File file sdCard Open font ttf Allocate a memory buffer to hold the font file times Es butter mew vinta ic lrille gt corsazs 17 Read the entire font file into the memory buffer file gt Read buffer file gt GetSize Create a memory stream to pass to the font drawing functions MemoryStream memoryFont buffer file gt GetSize Close the file as it is no longer needed sdCard Close file Display the text SolidBrush white OxFF OxFF OxFF led FillText 100 0f 100 0f memoryFont Hello 32 0f white Deallocate the memory delete buffer To ensure a font fits in the MoaTouch s limited memory however the size of the font file must be reduced to an absolute minimum To help users reduce the size of font files Comfile Technology has created a SubsetFont utility that can be used to remove unneeded glyphs from font files Please see the MoaTouch s support website to obtain this utility and it s documentation Comfile Technology MoaTouch User s Manual 31 of 124 MoaTouch User s Manual Layers Layers are independent visuals superimposed on one another to create a composite visual They are useful for separating a visual into logical parts that can be updated independently without impact
116. true Give each LED the chance to update its state for uint8 t i 0 i lt NUM OF LEDS i Update the UI with the latest state leds i Update return 0 Bowe eo Ue lo MoaTouch w lt W ZO 32 DI E a CF DOSO8 A O Moacon Comfile Technology MoaTouch User s Manual 86 of 124 MoaTouch User s Manual NVRam Class The NVRam class provides read and write access to the MoaTouch s non volatile memory so data can be retained on the MoaTouch between power cycles It is implemented as a singleton class whose instance can be accessed via the nvran identifier Methods size_t GetCapacityInBytes const Gets the capacity of the non volatile memory in bytes void Read uint8 t address void buffer size_t numOfBytes Read a given number of bytes numofBytes from the specified non volatile memory address address and copy the values into the given memory buffer buffer This method will throw a std range_error if address and numOfBytes implies and address not within the non volatile memory s capacity void Write uint8 t address const void buffer size t numOfBytes Read a given number of bytes numofBytes from the given memory buffer buffer and write the values to the specified non volatile memory address address This method will throw a std range_error if address and numOfBytes implies an address not within the non volatile memory s capacity Example This example
117. turns true if the given coordinate lies below this area bool IsOffBottomRightBound const Pointg point const Returns true if the given point is either to the right of this area below this area or both bool IsOffLeftBound float value const Returns true if the given coordinate lies to the left of this area Comfile Technology MoaTouch User s Manual 39 of 124 MoaTouch User s Manual bool IsOffRightBound float value const Returns true if the given coordinate lies to the right of this area bool IsOffTopBound float value const Returns true if the given coordinate lies above this area bool IsOffTopleftBound const Point amp point const Returns true if the given point is either to the left of this area above this area or both bool IsWithinHorizontalBounds float value const Returns ture if the given coordinate is greater than or equal to the left coordinate of this area and less than or equal to the right coordinate of this area bool IsWithinVerticalBounds float value const Returns true if the given coordinate is greater than or equal to the top coordinate of this area and less than or equal to the bottom coordinate of this area void SetHeight float value Sets the height of this area void SetLeft float x Sets the left most x coordinate of this area Setting this value does not change the width or height of this area It effectively moves the area along the x axis void SetTop float y Sets th
118. tus Enumeration An enumeration of specific connection states for TCP IP communication Items Closed 0x00 ARP 0x01 Init 0x13 Listening 0x14 SynSent 0x15 SynReceived 0x16 Established 0x17 FinWait 0x18 Closing 0x1A TimeWait 0x1B CloseWait 0x1C LastAck 0x1D UDP 0x22 IPRaw 0x32 MACRaw 0x42 PPOE 0x5F Methods Number GetNumber const Gets the socket s number for identification void Open uint16_t port Opens this socket using the given TCP IP port void Close Close this socket void Listen Listen for an incoming connection on this socket This socket should be opened first void Connect uint8_t oct3 uint8_t oct2 uint8 t octl uint8 t oct0 uintl6 t port Establish a connection with to a the given ip address individual octects on the specified port void Connect uint32 t ipAdddress uint16_t port Establish a connection with to a the given ip address 32 bit unsigned integer on the specified port void Disconnect Disconnect any established connections size_t GetRxCount const Gets the number of bytes received on this socket Status GetStatus const Gets the current connection state of this socket Comfile Technology MoaTouch User s Manual 108 of 124 MoaTouch User s Manual size_t Read void buffer size_t numOfBytes Read numOfBytes bytes from this socket s receive buffer and copy the data to buffer Returns the number of bytes actually read int ReadByt
119. uch User s Manual MemoryStream Class This class can be used to provide stream semantics to a memory buffer It can be useful for string fonts images or other user content in memory for use by some of the MoaTouch s drawing features It inherits from the FiniteStreamReader Class Constructors MemoryStream uint8 t buffer size t size Create a memory stream around the given buffer MemoryStream const MemoryStream source Copy constructor Methods virtual size t GetCurrentPosition 0 Reports the current position in the stream virtual size t GetSize const 0 Reports the total number of bytes in the stream size_t Read void buffer size_t numOfBytes Read numOfBytes from the current position in the stream and store the data read in buffer This method will also advance the current position in the stream by numOfBytes virtual void Seek size t position 0 Moves to the given position in the stream Example See Fonts and Text for a demonstration of this class Comfile Technology MoaTouch User s Manual 81 of 124 MoaTouch User s Manual ModbusRTUMaster Class This class allows the MoaTouch to function as a Modbus RTU master for controlling other PLCs over one of the MoaTouch s serial ports ModbusRTUMaster Status Enum An enumeration for identifying the current status of this class Items ReadyForRequest 0 Ready to begin a new query WaitingForResponse 1 Waiting for the respone from
120. unction sections fdata sections std c 11 I C Program Files x86 ComfileTools MoaTouch Tools include HelloWorld cpp o HelloWorld o arm none eabi g c mthumb mcpu cortex m4 mfpu fpv4 sp d16 mfloat abi softfp fsingle precision constant ffunction sections fdata sections std c 11 I C Program Files x86 ComfileTools MoaTouch Tools include main cpp o main o Explanation of each argument arm none eabi g The GNU C compiler c compile only don t link mcpu cortex m4 The MoaTouch s MCU is an ARM Cortex M4 mthumb The MoaTouch s MCU uses the ARM Thumb 2 instruction set mfpu fpv4 sp d16 mfloat abi softfp Use the ARM Cortex M4 s Floating Point Unit FPU fsingle precision constant treat floating point literals as a float type instead of a double type as the MoaTouch s FPU only supports single precision floating point gt ffunction sections fdata sections Used in collusion with the linker s gc sections to remove unused code and reduce the executable s size std c 11 Enabled C 11 features I C Program Files x86 ComfileTools MoaTouch Tools include The include folder containing the MoaTouch library header files VVVVV V Vv This will create two object files HelloWorld o and main o to be used by the linker in the next step Linking the Object Files Once the object files 0 files are created we can link them with the MoaTouch library and the toolchain s libraries to produce

Download Pdf Manuals

image

Related Search

Related Contents

2RII Operators Manual Over Serial Number 16000  Mergetool.com    V7 1 Year Extended Warranty for Product Value up to EUR 900 / £ 700  

Copyright © All rights reserved.
Failed to retrieve file