├── src ├── Picaso_XYposToDegree.h ├── Picaso_PrintDisk.h ├── Picaso_LedDigitsDisplay.h ├── Picaso_LedDigitsDisplaySigned.h ├── Picaso_KBRoutines.h ├── Picaso_PrintDisk.cpp ├── Picaso_LedDigitsDisplay.cpp ├── Picaso_ColourRoutines.h ├── Picaso_LedDigitsDisplaySigned.cpp ├── Picaso_XYposToDegree.cpp ├── Picaso_KBRoutines.cpp ├── Picaso_ColourRoutines.cpp ├── Picaso_Serial_4DLib.h └── Picaso_Const4D.h ├── logo.jpg ├── library.properties ├── .gitattributes ├── README.md ├── .gitignore ├── examples ├── Display_print │ └── Display_print.ino └── BigDemo │ ├── BigDemo.h │ └── BigDemo.ino └── LICENSE /src/Picaso_XYposToDegree.h: -------------------------------------------------------------------------------- 1 | int16_t XYposToDegree(int16_t curX, int16_t curY) ; 2 | -------------------------------------------------------------------------------- /logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4dsystems/Picaso-Serial-Arduino-Library/HEAD/logo.jpg -------------------------------------------------------------------------------- /src/Picaso_PrintDisk.h: -------------------------------------------------------------------------------- 1 | 2 | void PrintDisk(Picaso_Serial_4DLib Display, word hndl, long offset, word msglen, word msgid); 3 | 4 | void PrintDiskUnicode(Picaso_Serial_4DLib Display, word hndl, long offset, word msglen, word msgid); 5 | 6 | -------------------------------------------------------------------------------- /src/Picaso_LedDigitsDisplay.h: -------------------------------------------------------------------------------- 1 | #if (ARDUINO >= 100) 2 | #include "Arduino.h" // for Arduino 1.0 3 | #else 4 | #include "WProgram.h" // for Arduino 23 5 | #endif 6 | 7 | // WARNING, this code will crash if newval exceeds maximum displayable number 8 | void LedDigitsDisplay(Picaso_Serial_4DLib Display, word hndl, word newval, word index, word left, word Digits, word MinDigits, word WidthDigit, word LeadingBlanks) ; 9 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Picaso-Serial-Arduino-Library 2 | version=1.0.5 3 | author=4D Systems 4 | maintainer=4D Systems 5 | sentence=Provides library access to communicate with the 4D Systems Picaso processor, when configured in Serial/SPE mode 6 | paragraph=Arduino Library for 4D Systems Serial Environment for Picaso based modules 7 | category=Display 8 | url=https://github.com/4dsystems/Picaso-Serial-Arduino-Library 9 | architectures=* 10 | includes=Picaso_Serial_4DLib.h,Picaso_Const4D.h 11 | -------------------------------------------------------------------------------- /src/Picaso_LedDigitsDisplaySigned.h: -------------------------------------------------------------------------------- 1 | #if (ARDUINO >= 100) 2 | #include "Arduino.h" // for Arduino 1.0 3 | #else 4 | #include "WProgram.h" // for Arduino 23 5 | #endif 6 | 7 | // Warning, ensure correct number of digits are specified, especially if -ve numbers are required as minus sign 8 | // will overlay most significant digit if there are not enough digits. 9 | void LedDigitsDisplaySigned(Picaso_Serial_4DLib Display, word hndl, int16_t newval, word index, word left, word Digits, word MinDigits, word WidthDigit, word LeadingBlanks) ; 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /src/Picaso_KBRoutines.h: -------------------------------------------------------------------------------- 1 | #if defined(ARDUINO) && ARDUINO >= 100 2 | #include "Arduino.h" 3 | #else 4 | #include "WProgram.h" 5 | #endif 6 | 7 | #define KbDown 0 8 | #define KbMvt 1 9 | #define KbState 2 10 | #define KbIgn 3 11 | #define KbCaps 4 12 | #define KbShift1 5 13 | #define KbShift2 6 14 | #define KbCtrl1 7 15 | #define KbCtrl2 8 16 | #define KbLock 9 17 | #define KbButtons 10 18 | #define KbShiftCaps 11 19 | 20 | typedef void (*Callback) (int); 21 | 22 | void refreshstate(Picaso_Serial_4DLib Display, word hndl, int8_t iKB, int8_t * oKB) ; 23 | 24 | void kbDown(Picaso_Serial_4DLib Display, word hndl, int8_t iKB, int8_t * oKB, uint8_t * KBKeys, int8_t key, Callback handler) ; 25 | 26 | void kbUp(Picaso_Serial_4DLib Display, word hndl, int8_t iKB, int8_t * oKB) ; 27 | 28 | void setkeystate(Picaso_Serial_4DLib Display, word hndl, int8_t key, int8_t idx) ; 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Picaso_PrintDisk.cpp: -------------------------------------------------------------------------------- 1 | #if (ARDUINO >= 100) 2 | #include "Arduino.h" // for Arduino 1.0 3 | #else 4 | #include "WProgram.h" // for Arduino 23 5 | #endif 6 | 7 | #include "Picaso_Serial_4DLib.h" 8 | #include "Picaso_Const4D.h" 9 | 10 | void PrintDisk(Picaso_Serial_4DLib Display, word hndl, long offset, word msglen, word msgid) 11 | { 12 | char ch ; 13 | long res ; 14 | res = (long)msglen * msgid ; 15 | res += offset ; 16 | Display.file_Seek(hndl, res >> 16, res & 0xffff); 17 | do 18 | { 19 | ch = Display.file_GetC(hndl) ; 20 | Display.putCH(ch) ; 21 | } 22 | while (ch != 0) ; 23 | } 24 | 25 | void PrintDiskUnicode(Picaso_Serial_4DLib Display, word hndl, long offset, word msglen, word msgid) 26 | { 27 | word ch ; 28 | long res ; 29 | res = (long)msglen * msgid ; 30 | res += offset ; 31 | Display.file_Seek(hndl, res >> 16, res & 0xffff); 32 | do 33 | { 34 | ch = Display.file_GetW(hndl) ; 35 | Display.putCH(ch) ; 36 | } 37 | while (ch != 0) ; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/Picaso_LedDigitsDisplay.cpp: -------------------------------------------------------------------------------- 1 | #if (ARDUINO >= 100) 2 | #include "Arduino.h" // for Arduino 1.0 3 | #else 4 | #include "WProgram.h" // for Arduino 23 5 | #endif 6 | 7 | #include "Picaso_Serial_4DLib.h" 8 | #include "Picaso_Const4D.h" 9 | 10 | // WARNING, this code will crash if newval exceeds maximum displayable number 11 | void LedDigitsDisplay(Picaso_Serial_4DLib Display, word hndl, word newval, word index, word left, word Digits, word MinDigits, word WidthDigit, word LeadingBlanks) 12 | { 13 | word i, k, l, lb ; 14 | l = 1 ; 15 | for (i = 1; i < Digits; i++) 16 | l *= 10 ; 17 | lb = LeadingBlanks ; 18 | for (i = 0; i < Digits; i++) 19 | { 20 | k = newval / l ; 21 | newval -= k * l ; 22 | if ( lb && (i < Digits - MinDigits) ) 23 | { 24 | if (k == 0) 25 | k = 10 ; 26 | else 27 | lb = 0 ; 28 | } 29 | l /= 10 ; 30 | Display.img_SetWord(hndl, index, IMAGE_INDEX, k); 31 | Display.img_SetWord(hndl, index, IMAGE_XPOS, left+i*WidthDigit) ; 32 | Display.img_Show(hndl, index); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/Picaso_ColourRoutines.h: -------------------------------------------------------------------------------- 1 | // color conversion routines seem to be based on http://support.microsoft.com/kb/29240 2 | // My copy seem to have been around since the MSDOS days, I don't know if it came from another source 3 | #define HLSMAX 127 // HLS vary over 0-HLSMAX 4 | #define HLSMAXm2d3 HLSMAX* 2 / 3 5 | #define HLSMAXd12 HLSMAX / 12 6 | #define HLSMAXd6 HLSMAX / 6 7 | #define HLSMAXd2 HLSMAX / 2 8 | #define HLSMAXd3 HLSMAX / 3 9 | #define RGBMAX 127 // R,G, and B vary over 0-RGBMAX 10 | #define RGBMAXm2 RGBMAX*2 11 | // HLSMAX BEST IF DIVISIBLE BY 6 12 | // RGBMAX, HLSMAX must each fit in a byte. 13 | 14 | // Hue is undefined if Saturation is 0 (grey-scale) * 15 | // This value determines where the Hue scrollbar is 16 | // initially set for achromatic colors 17 | #define UNDEFINED 127 * 2 / 3 18 | 19 | uint16_t RGBs2COL(int16_t r, int16_t g, int16_t b) ; 20 | 21 | void c565toRGBs(int16_t i565, int16_t * red, int16_t * green, int16_t * blue); 22 | 23 | void RGB2HLS(int16_t red, int16_t green, int16_t blue, int16_t * h, int16_t * l, int16_t * s) ; 24 | 25 | uint16_t hue_RGB(int16_t Hin, int16_t M1, int16_t M2) ; 26 | 27 | void HLS2RGB(int16_t H, int16_t L, int16_t S, int16_t * r, int16_t * g, int16_t * b); 28 | 29 | -------------------------------------------------------------------------------- /src/Picaso_LedDigitsDisplaySigned.cpp: -------------------------------------------------------------------------------- 1 | #if (ARDUINO >= 100) 2 | #include "Arduino.h" // for Arduino 1.0 3 | #else 4 | #include "WProgram.h" // for Arduino 23 5 | #endif 6 | 7 | #include "Picaso_Serial_4DLib.h" 8 | #include "Picaso_Const4D.h" 9 | 10 | // Warning, ensure correct number of digits are specified, especially if -ve numbers are required as minus sign 11 | // will overlay most significant digit if there are not enough digits. 12 | void LedDigitsDisplaySigned(Picaso_Serial_4DLib Display, word hndl, int16_t newval, word index, word left, word Digits, word MinDigits, word WidthDigit, word LeadingBlanks) 13 | { 14 | int16_t i, m, lstb, nv; 15 | 16 | left = left + WidthDigit * (Digits-1) ; 17 | nv = newval ; 18 | lstb = 1 ; 19 | for (i = Digits; i > 0; i--) 20 | { 21 | m = nv % 10 ; 22 | if ( LeadingBlanks && (i <= Digits - MinDigits) ) 23 | { 24 | if (nv == 0) 25 | { 26 | m = 10 ; 27 | if (lstb == 1) 28 | lstb = i ; 29 | } 30 | } 31 | 32 | 33 | Display.img_SetWord(hndl, index, IMAGE_INDEX, abs(m)); 34 | Display.img_SetWord(hndl, index, IMAGE_XPOS, left) ; 35 | Display.img_Show(hndl, index); 36 | nv /= 10 ; 37 | 38 | left -= WidthDigit ; 39 | } 40 | if (newval < 0) 41 | { 42 | left += lstb * WidthDigit ; 43 | Display.img_SetWord(hndl, index, IMAGE_INDEX, 11); 44 | Display.img_SetWord(hndl, index, IMAGE_XPOS, left) ; 45 | Display.img_Show(hndl, index); 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![4D Logo](./logo.jpg) 2 | 3 | Picaso-Serial-Arduino-Library 4 | ============================= 5 | 6 | Arduino Library for 4D Systems Serial Environment for Picaso based modules 7 | 8 | ## Information 9 | 10 | This library provides high level functions for the Arduino, to ease communication with Picaso based modules when using the module configured for Serial. 11 | Please refer to the 4D Systems website, namingly the Workshop4 Product Page, for documentation regarding Workshop4, and its environments. 12 | 13 | ## Installation 14 | 15 | It is advisable to simply use the Arduino IDE's library manager to search and install Picaso Serial Arduino Library. 16 | 17 | For more information on the installation, please refer to the following documentation from Arduino: 18 | 19 | - Arduino 1.x: [Installing Libraries](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries) 20 | - Arduino 2.x: [Installing Libraries](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-installing-a-library) 21 | 22 | ## Example Sketch 23 | 24 | The BigDemo example is included with this library and located in the examples folder 25 | Please load and compile the BigDemo sketch to run a large demo, demonstrating a majority of the functions and features the library provides. 26 | 27 | ## Questions/Issues? 28 | 29 | Please sign up for our Forum and ask a question there, or submit a Tech Support Ticket from our website. 30 | http://forum.4dsystems.com.au or http://www.4dsystems.com.au/support 31 | -------------------------------------------------------------------------------- /src/Picaso_XYposToDegree.cpp: -------------------------------------------------------------------------------- 1 | #if defined(ARDUINO) && ARDUINO >= 100 2 | #include "Arduino.h" 3 | #else 4 | #include "WProgram.h" 5 | #endif 6 | // 7 | // Routine to convert X/Y (Relative to 0,0) position into Degrees 8 | // 0 Degrees is straight down to suit rotary objects 9 | // 10 | 11 | const uint8_t arctan[] = {0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 12 | 6, 6, 7, 7, 8, 9, 9, 10, 10, 11, 13 | 11, 12, 12, 13, 13, 14, 15, 15, 16, 16, 14 | 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 15 | 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 16 | 27, 27, 27, 28, 28, 29, 29, 30, 30, 31, 17 | 31, 31, 32, 32, 33, 33, 33, 34, 34, 35, 18 | 35, 35, 36, 36, 37, 37, 37, 38, 38, 38, 19 | 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 20 | 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, 45} ; 21 | 22 | int16_t XYposToDegree(int16_t curX, int16_t curY) 23 | { 24 | int16_t delta, deg, adj ; 25 | if (curY < 0) 26 | { 27 | if (curX < 0) 28 | { 29 | adj = 1 ; 30 | deg = 90 ; 31 | } 32 | else 33 | { 34 | adj = 2 ; 35 | deg = 180 ; 36 | } 37 | } 38 | else 39 | { 40 | if (curX < 0) 41 | { 42 | deg = 0 ; 43 | adj = 2 ; 44 | } 45 | else 46 | { 47 | deg = 270 ; 48 | adj = 1 ; 49 | } 50 | } 51 | 52 | curX = abs(curX) ; 53 | curY = abs(curY) ; 54 | if (curX < curY) 55 | adj &= 1 ; 56 | else 57 | { 58 | adj &= 2 ; 59 | delta = curX ; 60 | curX = curY ; 61 | curY = delta ; 62 | } 63 | delta = arctan[(curX * 100) / curY] ; 64 | if (adj) 65 | deg += 90 - delta ; 66 | else 67 | deg += delta ; 68 | 69 | return deg ; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /examples/Display_print/Display_print.ino: -------------------------------------------------------------------------------- 1 | //Simple Demo that demonstrates 'print' and 'println' new functionality. 2 | 3 | #define DisplaySerial Serial 4 | 5 | //-------Picaso DISPLAYS------- 6 | 7 | #include 8 | #include 9 | 10 | //use Serial0 to communicate with the display. 11 | Picaso_Serial_4DLib Display(&DisplaySerial); 12 | 13 | //---------END----------------- 14 | 15 | void setup() { 16 | //For handling errors 17 | Display.Callback4D = mycallback ; 18 | 19 | //5 second timeout on all commands 20 | Display.TimeLimit4D = 5000 ; 21 | 22 | DisplaySerial.begin(9600) ; 23 | 24 | //--------------------------------Optional reset routine----------------------------------- 25 | //Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2) 26 | //If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below. 27 | //If using jumper wires, reverse the logic states below. 28 | //Refer to the accompanying application note for important information. 29 | pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset) 30 | digitalWrite(4, 1); // Reset the Display via D4 31 | delay(100); 32 | digitalWrite(4, 0); // unReset the Display via D4 33 | //-----------------------------------------END--------------------------------------------- 34 | 35 | delay (5000); //let the display start up 36 | 37 | Display.gfx_ScreenMode(PORTRAIT); 38 | //Display.gfx_BGcolour(WHITE) ; //change background color to white 39 | Display.gfx_Cls(); //clear the screen 40 | 41 | char a = 'A'; 42 | char a2 = 'B'; 43 | int b = 1234; 44 | int b2 = -1234; 45 | long c = 123456; 46 | long c2 = -123456; 47 | String string = "This is string class"; 48 | char charr[30] = "This is const char array"; 49 | float d = 123.456789; 50 | float d2 = -123.456789; 51 | float nan = NAN; 52 | float inf = INFINITY; 53 | float ovf1 = 5294967040.0; 54 | float ovf2 = -5294967040.0; 55 | 56 | Display.print(a); Display.print(' '); 57 | Display.println(a2); 58 | Display.print(b); Display.print(' '); 59 | Display.println(b2); 60 | Display.print(c); Display.print(' '); 61 | Display.println(c2); 62 | Display.println("This is String"); 63 | Display.println(F("This is Flashstring")); // COMMENT OUT FOR ARDUINO DUE, NOT SUPPORTED 64 | Display.println(string); 65 | Display.println(charr); 66 | Display.println(d,6); 67 | Display.println(d2, 3); 68 | Display.println(nan); 69 | Display.println(inf); 70 | Display.println(ovf1); 71 | Display.println(ovf2); 72 | 73 | } 74 | 75 | void loop() 76 | { 77 | 78 | } 79 | 80 | void mycallback(int ErrCode, unsigned char Errorbyte) 81 | { 82 | // Pin 13 has an LED connected on most Arduino boards. Just give it a name 83 | int led = 13; 84 | pinMode(led, OUTPUT); 85 | while(1) 86 | { 87 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 88 | delay(200); // wait for 200 ms 89 | digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 90 | delay(200); // wait for 200 ms 91 | } 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/Picaso_KBRoutines.cpp: -------------------------------------------------------------------------------- 1 | #include "Picaso_Serial_4DLib.h" 2 | #include "Picaso_Const4D.h" 3 | 4 | #include "Picaso_KBRoutines.h" 5 | 6 | #define KbShiftBit 01 7 | #define KbCapsBit 02 8 | #define KbShiftCapsBits 03 9 | #define KbCtrlBit 04 10 | 11 | #if (ARDUINO >= 100) 12 | #include "Arduino.h" // for Arduino 1.0 13 | #else 14 | #include "WProgram.h" // for Arduino 23 15 | #endif 16 | 17 | void refreshstate(Picaso_Serial_4DLib Display, word hndl, int8_t iKB, int8_t * oKB) 18 | { 19 | int8_t shifted ; 20 | shifted = oKB[KbState] & KbShiftCapsBits ; 21 | if (!shifted || (shifted == KbShiftCapsBits)) 22 | { 23 | shifted = 0 ; 24 | oKB[KbCaps] = 0 ; 25 | } 26 | else 27 | { 28 | shifted = 1 ; 29 | oKB[KbCaps] = 2 ; 30 | } 31 | setkeystate(Display, hndl, iKB, shifted) ; 32 | if (oKB[KbState] & KbCapsBit) 33 | setkeystate(Display, hndl, iKB + oKB[KbLock],1) ; 34 | if ((oKB[KbState] & KbShiftBit) && (shifted)) 35 | { 36 | setkeystate(Display, hndl, iKB + oKB[KbShift1],1) ; 37 | setkeystate(Display, hndl, iKB + oKB[KbShift2],1) ; 38 | } 39 | if (oKB[KbState] & KbCtrlBit) 40 | { 41 | setkeystate(Display, hndl, iKB +oKB[KbCtrl1],1) ; 42 | setkeystate(Display, hndl, iKB + oKB[KbCtrl2],1) ; 43 | } 44 | } 45 | 46 | 47 | void kbDown(Picaso_Serial_4DLib Display, word hndl, int8_t iKB, int8_t * oKB, uint8_t * KBKeys, int8_t key, Callback handler) 48 | { 49 | int8_t keyval ; 50 | oKB[KbMvt] = 1 ; 51 | oKB[KbIgn] = 0 ; 52 | if ((key == oKB[KbShift1]) || (key == oKB[KbShift2])) 53 | { 54 | if (oKB[KbState] & KbShiftBit) 55 | { 56 | oKB[KbState] &= ~KbShiftBit ; 57 | oKB[KbMvt] = 0 ; 58 | } 59 | else 60 | oKB[KbState] |= KbShiftBit ; 61 | refreshstate(Display, hndl, iKB, oKB) ; 62 | oKB[KbIgn] = 1 ; 63 | } 64 | else if ((key == oKB[KbCtrl1]) || (key == oKB[KbCtrl2])) 65 | { 66 | if (oKB[KbState] & KbCtrlBit) 67 | { 68 | oKB[KbState] &= ~KbCtrlBit ; 69 | oKB[KbMvt] = 0 ; 70 | } 71 | else 72 | oKB[KbState] |= KbCtrlBit ; 73 | setkeystate(Display, hndl, iKB + oKB[KbCtrl1],oKB[KbMvt]) ; 74 | key = oKB[KbCtrl2] ; 75 | oKB[KbIgn] = 1 ; 76 | } 77 | else if (key == oKB[KbLock]) 78 | { 79 | if (oKB[KbState] & KbCapsBit) 80 | { 81 | oKB[KbState] &= ~KbCapsBit ; 82 | oKB[KbMvt] = 0 ; 83 | } 84 | else 85 | oKB[KbState] |= KbCapsBit ; 86 | refreshstate(Display, hndl, iKB, oKB) ; 87 | oKB[KbIgn] = 1 ; 88 | } 89 | 90 | if (!oKB[KbIgn]) 91 | { 92 | if (oKB[KbShiftCaps]) 93 | keyval = (oKB[KbState] & KbShiftCapsBits) * oKB[KbButtons] - 1 ; 94 | else if (((oKB[KbState] & KbShiftCapsBits) == 0) || ((oKB[KbState] & KbShiftCapsBits) == KbShiftCapsBits)) 95 | keyval = - 1 ; 96 | else 97 | keyval = oKB[KbButtons] - 1 ; 98 | keyval = KBKeys[key+keyval] ; 99 | if (oKB[KbState] & KbCtrlBit) keyval &= 0x9F ; 100 | handler(keyval & 0xFF) ; 101 | setkeystate(Display, hndl, iKB + key,oKB[KbMvt]+oKB[KbCaps]) ; 102 | } 103 | oKB[KbDown] = key ; 104 | } 105 | 106 | void setkeystate(Picaso_Serial_4DLib Display, word hndl, int8_t key, int8_t idx) 107 | { 108 | Display.img_SetWord(hndl, key,IMAGE_INDEX, idx); 109 | Display.img_Show(hndl,key) ; 110 | } 111 | 112 | void kbUp(Picaso_Serial_4DLib Display, word hndl, int8_t iKB, int8_t * oKB) 113 | { 114 | if (!oKB[KbIgn]) 115 | { 116 | setkeystate(Display, hndl, iKB + oKB[KbDown], oKB[KbCaps]) ; 117 | if (oKB[KbState] & KbShiftBit) 118 | { 119 | oKB[KbState] &= ~KbShiftBit ; 120 | refreshstate(Display, hndl, iKB, oKB) ; 121 | } 122 | if (oKB[KbState] & KbCtrlBit) 123 | { 124 | oKB[KbState] &= ~KbCtrlBit ; 125 | setkeystate(Display, hndl, iKB + oKB[KbCtrl1],0) ; 126 | setkeystate(Display, hndl, iKB + oKB[KbCtrl2],0) ; 127 | } 128 | oKB[KbDown] = -1 ; 129 | } 130 | } 131 | 132 | -------------------------------------------------------------------------------- /src/Picaso_ColourRoutines.cpp: -------------------------------------------------------------------------------- 1 | #if (ARDUINO >= 100) 2 | #include "Arduino.h" // for Arduino 1.0 3 | #else 4 | #include "WProgram.h" // for Arduino 23 5 | #endif 6 | 7 | //#include "Picaso_Serial_4DLib.h" 8 | //#include "Picaso_Const4D.h" 9 | 10 | #define HLSMAX 127 // HLS vary over 0-HLSMAX 11 | #define HLSMAXm2d3 (HLSMAX* 2 / 3 ) 12 | #define HLSMAXd12 (HLSMAX / 12 ) 13 | #define HLSMAXd6 (HLSMAX / 6 ) 14 | #define HLSMAXd2 (HLSMAX / 2 ) 15 | #define HLSMAXd3 (HLSMAX / 3 ) 16 | #define RGBMAX 127 // R,G, and B vary over 0-RGBMAX 17 | #define RGBMAXm2 (RGBMAX*2) 18 | // HLSMAX BEST IF DIVISIBLE BY 6 19 | // RGBMAX, HLSMAX must each fit in a byte. 20 | 21 | // Hue is undefined if Saturation is 0 (grey-scale) * 22 | // This value determines where the Hue scrollbar is 23 | // initially set for achromatic colors 24 | #define UNDEFINED (127 * 2 / 3 ) 25 | 26 | // color conversion routines seem to be based on http://support.microsoft.com/kb/29240 27 | // My copy seem to have been around since the MSDOS days, I don't know if it came from another source 28 | 29 | uint16_t RGBs2COL(int16_t r, int16_t g, int16_t b) 30 | { 31 | return (b >> 2) | (g & 0x7E) << 4 | (r & 0x7c) << 9 ; 32 | } 33 | 34 | void c565toRGBs(int16_t i565, int16_t * red, int16_t * green, int16_t * blue) 35 | { 36 | *red = (i565 & 0xF800) >> 9 ; 37 | *green = (i565 & 0x07E0) >> 4 ; 38 | *blue = (i565 & 0x001F) << 2 ; 39 | } 40 | 41 | void RGB2HLS(int16_t red, int16_t green, int16_t blue, int16_t * h, int16_t * l, int16_t * s) 42 | { 43 | int16_t cMax, cMin, Rdelta, Gdelta, Bdelta, cMpM, cMmM ; 44 | // calculate lightness 45 | cMax = max( max(red,green), blue); 46 | cMin = min( min(red,green), blue); 47 | cMpM = cMax+cMin ; 48 | cMmM = cMax-cMin ; 49 | 50 | *l = ( (cMpM*HLSMAX) + RGBMAX ) / RGBMAXm2; 51 | 52 | if (cMax == cMin) // r=g=b --> achromatic case 53 | { 54 | *s = 0; 55 | *h = UNDEFINED; 56 | } 57 | else // chromatic case 58 | { 59 | // saturation 60 | if (*l <= (HLSMAX/2)) 61 | *s = ( (cMmM*HLSMAX) + (cMpM / 2) ) / cMpM ; 62 | else 63 | *s = ( (cMmM*HLSMAX) + ((RGBMAXm2-cMpM) / 2) ) / (RGBMAXm2-cMpM); 64 | 65 | // hue 66 | Rdelta = ( ((cMax-red)* HLSMAXd6) + (cMmM / 2) ) / cMmM; 67 | Gdelta = ( ((cMax-green)* HLSMAXd6) + (cMmM / 2) ) / cMmM; 68 | Bdelta = ( ((cMax-blue)* HLSMAXd6) + (cMmM / 2) ) / cMmM; 69 | 70 | if (red == cMax) 71 | *h = Bdelta - Gdelta ; 72 | else if (green == cMax) 73 | *h = HLSMAXd3 + Rdelta - Bdelta ; 74 | else 75 | *h = HLSMAXm2d3 + Gdelta - Rdelta; 76 | 77 | if (*h < 0) *h += HLSMAX; 78 | if (*h > HLSMAX) *h -= HLSMAX; 79 | } 80 | } 81 | 82 | int16_t hue_RGB(int16_t Hin, int16_t M1, int16_t M2) 83 | { 84 | int16_t Value ; 85 | if (Hin < 0) 86 | Hin += HLSMAX ; 87 | else if (Hin > HLSMAX) 88 | Hin -= HLSMAX ; 89 | 90 | if (Hin < HLSMAXd6) 91 | Value = M1 + ( (M2 - M1) * Hin + HLSMAXd12 ) / HLSMAXd6 ; 92 | else if (Hin < HLSMAXd2 ) 93 | Value = M2 ; 94 | else if (Hin < HLSMAXm2d3) 95 | Value = M1 + ( (M2 - M1) * (HLSMAXm2d3 - Hin) + HLSMAXd12) / HLSMAXd6 ; 96 | else 97 | Value = M1 ; 98 | return Value ; 99 | } 100 | 101 | void HLS2RGB(int16_t H, int16_t L, int16_t S, int16_t * red, int16_t * green, int16_t * blue) 102 | { 103 | int16_t M1, M2 ; 104 | 105 | if (S == 0) 106 | { 107 | *red = L ; 108 | *green = L ; 109 | *blue = L ; 110 | } 111 | else 112 | { 113 | if (L <= HLSMAXd2) 114 | M2 = (L * (HLSMAX + S) + HLSMAXd2) / HLSMAX ; 115 | else 116 | M2 = L + S - ((L * S + HLSMAXd2) / HLSMAX) ; 117 | 118 | M1 = 2 * L - M2 ; 119 | // Determine levels of primary colours. 120 | if ((H > HLSMAX ) || (H < 0)) H = 0 ; 121 | *red = hue_RGB( H+HLSMAXd3, M1, M2 ) ; 122 | *green = hue_RGB( H, M1, M2 ) ; 123 | *blue = hue_RGB( H-HLSMAXd3, M1, M2 ) ; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/Picaso_Serial_4DLib.h: -------------------------------------------------------------------------------- 1 | // SPE Version 1.2 added peekM and pokeM 2 | // SPE Version 1.1 added bus_ and pin_ functions 3 | /* 4 | 4DSerial - Library for 4D Systems Serial Environment. 5 | Released into the public domain. 6 | */ 7 | 8 | #ifndef Picaso_Serial_4DLib_h 9 | #define Picaso_Serial_4DLib_h 10 | 11 | #if (ARDUINO >= 100) 12 | #include "Arduino.h" // for Arduino 1.0 13 | #else 14 | #include "WProgram.h" // for Arduino 23 15 | #endif 16 | 17 | #include "Picaso_Const4D.h" // Defines for 4dgl constants, generated by conversion of 4DGL constants to target language 18 | #include 19 | 20 | #ifdef AVR 21 | #include // uncomment this line to add direct support for SoftwareSerial 22 | // #include // uncomment this line to add direct support for AltSoftSerial (Note: AltSoftSerial needs to be installed in Arduino IDE) 23 | #endif 24 | 25 | #define DEC 10 26 | #define HEX 16 27 | #define OCT 8 28 | #define BIN 2 29 | 30 | typedef void (*Tcallback4D)(int, unsigned char); 31 | 32 | class Picaso_Serial_4DLib 33 | { 34 | public: 35 | Picaso_Serial_4DLib(Stream * virtualPort, void (*setBaudRateHndl)(unsigned long) = NULL); 36 | Picaso_Serial_4DLib(HardwareSerial * serial); 37 | #ifdef SoftwareSerial_h 38 | Picaso_Serial_4DLib(SoftwareSerial * serial); 39 | #endif 40 | #ifdef AltSoftSerial_h 41 | Picaso_Serial_4DLib(AltSoftSerial * serial); 42 | #endif 43 | Tcallback4D Callback4D ; 44 | 45 | //Compound 4D Routines 46 | word bus_In(); 47 | void bus_Out(word Bits); 48 | word bus_Read(); 49 | void bus_Set(word IOMap); 50 | void bus_Write(word Bits); 51 | word charheight(char TestChar); 52 | word charwidth(char TestChar); 53 | word file_Close(word Handle); 54 | word file_Count(char * Filename); 55 | word file_Dir(char * Filename); 56 | word file_Erase(char * Filename); 57 | word file_Error(); 58 | word file_Exec(char * Filename, word ArgCount, t4DWordArray Args); 59 | word file_Exists(char * Filename); 60 | word file_FindFirst(char * Filename); 61 | word file_FindNext(); 62 | char file_GetC(word Handle); 63 | word file_GetS(char * StringIn, word Size, word Handle); 64 | word file_GetW(word Handle); 65 | word file_Image(word X, word Y, word Handle); 66 | word file_Index(word Handle, word HiSize, word LoSize, word Recordnum); 67 | word file_LoadFunction(char * Filename); 68 | word file_LoadImageControl(char * Datname, char * GCIName, word Mode); 69 | word file_Mount(); 70 | word file_Open(char * Filename, char Mode); 71 | word file_PlayWAV(char * Filename); 72 | word file_PutC(char Character, word Handle); 73 | word file_PutS(char * StringOut, word Handle); 74 | word file_PutW(word Word, word Handle); 75 | word file_Read(t4DByteArray Data, word Size, word Handle); 76 | word file_Rewind(word Handle); 77 | word file_Run(char * Filename, word ArgCount, t4DWordArray Args); 78 | word file_ScreenCapture(word X, word Y, word Width, word Height, word Handle); 79 | word file_Seek(word Handle, word HiWord, word LoWord); 80 | word file_Size(word Handle, word * HiWord, word * LoWord); 81 | word file_Tell(word Handle, word * HiWord, word * LoWord); 82 | void file_Unmount(); 83 | word file_Write(word Size, t4DByteArray Source, word Handle); 84 | word gfx_BevelShadow(word Value); 85 | word gfx_BevelWidth(word Value); 86 | word gfx_BGcolour(word Color); 87 | void gfx_Button(word Up, word x, word y, word buttonColour, word txtColour, word font, word txtWidth, word txtHeight, char * text); 88 | void gfx_ChangeColour(word OldColor, word NewColor); 89 | void gfx_Circle(word X, word Y, word Radius, word Color); 90 | void gfx_CircleFilled(word X, word Y, word Radius, word Color); 91 | void gfx_Clipping(word OnOff); 92 | void gfx_ClipWindow(word X1, word Y1, word X2, word Y2); 93 | void gfx_Cls(); 94 | word gfx_Contrast(word Contrast); 95 | void gfx_Ellipse(word X, word Y, word Xrad, word Yrad, word Color); 96 | void gfx_EllipseFilled(word X, word Y, word Xrad, word Yrad, word Color); 97 | word gfx_FrameDelay(word Msec); 98 | word gfx_Get(word Mode); 99 | word gfx_GetPixel(word X, word Y); 100 | void gfx_Line(word X1, word Y1, word X2, word Y2, word Color); 101 | word gfx_LinePattern(word Pattern); 102 | void gfx_LineTo(word X, word Y); 103 | void gfx_MoveTo(word X, word Y); 104 | word gfx_Orbit(word Angle, word Distance, word * Xdest, word * Ydest); 105 | word gfx_OutlineColour(word Color); 106 | void gfx_Panel(word Raised, word X, word Y, word Width, word Height, word Color); 107 | void gfx_Polygon(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color); 108 | void gfx_PolygonFilled(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color); 109 | void gfx_Polyline(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color); 110 | void gfx_PutPixel(word X, word Y, word Color); 111 | void gfx_Rectangle(word X1, word Y1, word X2, word Y2, word Color); 112 | void gfx_RectangleFilled(word X1, word Y1, word X2, word Y2, word Color); 113 | void gfx_ScreenCopyPaste(word Xs, word Ys, word Xd, word Yd, word Width, word Height); 114 | word gfx_ScreenMode(word ScreenMode); 115 | void gfx_Set(word Func, word Value); 116 | void gfx_SetClipRegion(); 117 | word gfx_Slider(word Mode, word X1, word Y1, word X2, word Y2, word Color, word Scale, word Value); 118 | word gfx_Transparency(word OnOff); 119 | word gfx_TransparentColour(word Color); 120 | void gfx_Triangle(word X1, word Y1, word X2, word Y2, word X3, word Y3, word Color); 121 | void gfx_TriangleFilled(word X1, word Y1, word X2, word Y2, word X3, word Y3, word Color); 122 | word img_ClearAttributes(word Handle, word Index, word Value); 123 | word img_Darken(word Handle, word Index); 124 | word img_Disable(word Handle, word Index); 125 | word img_Enable(word Handle, word Index); 126 | word img_GetWord(word Handle, word Index, word Offset ); 127 | word img_Lighten(word Handle, word Index); 128 | word img_SetAttributes(word Handle, word Index, word Value); 129 | word img_SetPosition(word Handle, word Index, word Xpos, word Ypos); 130 | word img_SetWord(word Handle, word Index, word Offset , word Word); 131 | word img_Show(word Handle, word Index); 132 | word img_Touched(word Handle, word Index); 133 | word media_Flush(); 134 | void media_Image(word X, word Y); 135 | word media_Init(); 136 | word media_RdSector(t4DSector SectorIn); 137 | word media_ReadByte(); 138 | word media_ReadWord(); 139 | void media_SetAdd(word HiWord, word LoWord); 140 | void media_SetSector(word HiWord, word LoWord); 141 | void media_Video(word X, word Y); 142 | void media_VideoFrame(word X, word Y, word Framenumber); 143 | word media_WriteByte(word Byte); 144 | word media_WriteWord(word Word); 145 | word media_WrSector(t4DSector SectorOut); 146 | word mem_Free(word Handle); 147 | word mem_Heap(); 148 | word pin_HI(word Pin); 149 | word peekM(word Address); 150 | word pin_LO(word Pin); 151 | word pin_Read(word Pin); 152 | word pin_Set(word Mode, word Pin); 153 | void putCH(word WordChar); 154 | void pokeM(word Address, word WordValue) ; 155 | word putstr(char * InString); 156 | //---------------------print----------------------/ 157 | 158 | void print(const __FlashStringHelper *); 159 | void print(const String &); 160 | void print(const char[]); 161 | void print(char); 162 | void print(unsigned char, int = DEC); 163 | void print(int, int = DEC); 164 | void print(unsigned int, int = DEC); 165 | void print(long, int = DEC); 166 | void print(unsigned long n, int = DEC); 167 | void print(double, int = 2); 168 | 169 | void println(const __FlashStringHelper *); 170 | void println(const String &); 171 | void println(const char[]); 172 | void println(char); 173 | void println(unsigned char, int = DEC); 174 | void println(int, int = DEC); 175 | void println(unsigned int, int = DEC); 176 | void println(long, int = DEC); 177 | void println(unsigned long, int = DEC); 178 | void println(double, int = 2); 179 | 180 | //------------------------------------------------/ 181 | void snd_BufSize(word Bufsize); 182 | void snd_Continue(); 183 | void snd_Pause(); 184 | word snd_Pitch(word Pitch); 185 | word snd_Playing(); 186 | void snd_Stop(); 187 | void snd_Volume(word Volume); 188 | word sys_Sleep(word Units); 189 | void touch_DetectRegion(word X1, word Y1, word X2, word Y2); 190 | word touch_Get(word Mode); 191 | void touch_Set(word Mode); 192 | word txt_Attributes(word Attribs); 193 | word txt_BGcolour(word Color); 194 | word txt_Bold(word Bold); 195 | word txt_FGcolour(word Color); 196 | word txt_FontID(word FontNumber); 197 | word txt_Height(word Multiplier); 198 | word txt_Inverse(word Inverse); 199 | word txt_Italic(word Italic); 200 | void txt_MoveCursor(word Line, word Column); 201 | word txt_Opacity(word TransparentOpaque); 202 | void txt_Set(word Func, word Value); 203 | word txt_Underline(word Underline); 204 | word txt_Width(word Multiplier); 205 | word txt_Wrap(word Position); 206 | word txt_Xgap(word Pixels); 207 | word txt_Ygap(word Pixels); 208 | word file_CallFunction(word Handle, word ArgCount, t4DWordArray Args); 209 | word sys_GetModel(char * ModelStr); 210 | word sys_GetVersion(); 211 | word sys_GetPmmC(); 212 | word writeString(word Handle, char * StringOut); 213 | word readString(word Handle, char * StringIn); 214 | void blitComtoDisplay(word X, word Y, word Width, word Height, t4DByteArray Pixels); 215 | word file_FindFirstRet(char * Filename, char * StringIn); 216 | word file_FindNextRet(char * StringIn); 217 | bool setbaudWait(word Newrate); 218 | void GetAck(void); 219 | 220 | //4D Global Variables Used 221 | int Error4D; // Error indicator, used and set by Intrinsic routines 222 | unsigned char Error4D_Inv; // Error byte returned from com port, onl set if error = Err_Invalid 223 | // int Error_Abort4D; // if true routines will abort when detecting an error 224 | unsigned long TimeLimit4D = 2000; // time limit in ms for total serial command duration, 2000 (2 seconds) should be adequate for most commands 225 | // assuming a reasonable baud rate AND low latency AND 0 for the Serial Delay Parameter 226 | // temporary increase might be required for very long (bitmap write, large image file opens) 227 | // or indeterminate (eg file_exec, file_run, file_callFunction) commands 228 | 229 | private: 230 | bool unknownSerial = false; 231 | Stream * _virtualPort; 232 | unsigned long GetBaudRate(word Newrate); 233 | void (*setBaudRateExternal)(unsigned long newRate); 234 | void (Picaso_Serial_4DLib::*setBaudRateInternal)(unsigned long newRate); 235 | 236 | void exSetBaudRateHndl(unsigned long newRate); 237 | void hwSetBaudRateHndl(unsigned long newRate); 238 | #ifdef SoftwareSerial_h 239 | void swSetBaudRateHndl(unsigned long newRate); 240 | #endif 241 | #ifdef AltSoftSerial_h 242 | void alSetBaudRateHndl(unsigned long newRate); 243 | #endif 244 | 245 | //Intrinsic 4D Routines 246 | void WriteChars(char * charsout); 247 | void WriteBytes(char * Source, int Size); 248 | void WriteWords(word * Source, int Size); 249 | void getbytes(char * data, int size); 250 | word GetWord(void); 251 | void getString(char * outStr, int strLen); 252 | word GetAckResp(void); 253 | word GetAckRes2Words(word * word1, word * word2); 254 | void GetAck2Words(word * word1, word * word2); 255 | word GetAckResSector(t4DSector Sector); 256 | word GetAckResStr(char * OutStr); 257 | word GetAckResData(t4DByteArray OutData, word size); 258 | 259 | void printNumber(unsigned long, uint8_t); 260 | void printFloat(double number, uint8_t digits); 261 | 262 | }; 263 | 264 | #endif 265 | -------------------------------------------------------------------------------- /examples/BigDemo/BigDemo.h: -------------------------------------------------------------------------------- 1 | #define maxrates 20 2 | 3 | #define gfx2demogci "gfx2demo.gci" 4 | #define gfx2demodat "gfx2demo.dat" 5 | #define functest "kbfunc.4fn" 6 | #define functestg "kbfunc.gci" 7 | #define functestd "kbfunc.dat" 8 | #define soundtest "space.wav" 9 | #define testdat "test.dat" 10 | 11 | typedef struct 12 | { 13 | int recnum ; 14 | char values[5] ; 15 | char idx ; 16 | } datar ; 17 | 18 | const char Image[2054] PROGMEM = {0, 32, 0, 32, 16, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 19 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8C, 0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, 0x51, 0x10, 0xa2, 0x10, 0xa2, 0x8C, 0x51, 0xFF, 0xFF, 0xFF, 0xFF, 94 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 95 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 96 | 0xFF, 0xFF, 0x8C, 0x51, 0x8C, 0x51, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 97 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} ; 98 | ; 99 | -------------------------------------------------------------------------------- /src/Picaso_Const4D.h: -------------------------------------------------------------------------------- 1 | // SPE Version 1.2 added peekM and pokeM functions 2 | // SPE Version 1.1 added bus_ and pin_ functions 3 | // undef windows definitions that are also 4DGL definitions 4 | #ifdef TRANSPARENT 5 | #undef TRANSPARENT 6 | #endif 7 | #ifdef OPAQUE 8 | #undef OPAQUE 9 | #endif 10 | #ifdef BAUD_110 11 | #undef BAUD_110 12 | #endif 13 | #ifdef BAUD_300 14 | #undef BAUD_300 15 | #endif 16 | #ifdef BAUD_600 17 | #undef BAUD_600 18 | #endif 19 | #ifdef BAUD_1200 20 | #undef BAUD_1200 21 | #endif 22 | #ifdef BAUD_2400 23 | #undef BAUD_2400 24 | #endif 25 | #ifdef BAUD_4800 26 | #undef BAUD_4800 27 | #endif 28 | #ifdef BAUD_9600 29 | #undef BAUD_9600 30 | #endif 31 | #ifdef BAUD_14400 32 | #undef BAUD_14400 33 | #endif 34 | #ifdef BAUD_19200 35 | #undef BAUD_19200 36 | #endif 37 | #ifdef BAUD_38400 38 | #undef BAUD_38400 39 | #endif 40 | #ifdef BAUD_57600 41 | #undef BAUD_57600 42 | #endif 43 | #ifdef BAUD_115200 44 | #undef BAUD_115200 45 | #endif 46 | 47 | // baud divisor rates for setbaud(n); 48 | #define MIDI 9 49 | #define BAUD_110 0 50 | #define BAUD_300 1 51 | #define BAUD_600 2 52 | #define BAUD_1200 3 53 | #define BAUD_2400 4 54 | #define BAUD_4800 5 55 | #define BAUD_9600 6 56 | #define BAUD_14400 7 57 | #define BAUD_19200 8 58 | #define BAUD_31250 9 59 | #define BAUD_38400 10 60 | #define BAUD_56000 11 61 | #define BAUD_57600 12 62 | #define BAUD_115200 13 63 | #define BAUD_128000 14 64 | #define BAUD_256000 15 65 | #define BAUD_300000 16 66 | #define BAUD_375000 17 67 | #define BAUD_500000 18 68 | #define BAUD_600000 19 69 | 70 | //------------------------------------------------------------------// 71 | // CONSTANTS 72 | //------------------------------------------------------------------// 73 | 74 | // generic constants 75 | #define ENABLE 1 76 | #define DISABLE 0 77 | #define HI 1 78 | #define LO 0 79 | #define INPUT4d 1 80 | #define OUTPUT4d 0 81 | #define ON 1 82 | #define OFF 0 83 | 84 | //------------------------------------------------------------------------------ 85 | // Pin related constants 86 | //------------------------------------------------------------------------------ 87 | #define IO1_PIN 1 // pin 2 J1 88 | #define IO2_PIN 2 // pin 1 J1 89 | #define IO3_PIN 3 // pin 3 J1 90 | #define IO4_PIN 4 // pin 5 J1 (also used for BUS_RD) 91 | #define IO5_PIN 5 // pin 9 J2 (also used for BUS_WR) 92 | #define BUS_RD_PIN 4 // pin 5 J1 (alias IO4_PIN) 93 | #define BUS_WR_PIN 5 // pin 9 J2 (alias IO5_PIN) 94 | #define BACKLITE 6 // backlite control pin 95 | #define AUDIO_ENABLE 7 // amplifier chip control pin 96 | #define BUS_0 8 // pin 27 of J1 97 | #define BUS_1 9 // pin 25 of J1 98 | #define BUS_2 10 // pin 23 of J1 99 | #define BUS_3 11 // pin 21 of J1 100 | #define BUS_4 12 // pin 19 of J1 101 | #define BUS_5 13 // pin 17 of J1 102 | #define BUS_6 14 // pin 13 of J2 103 | #define BUS_7 15 // pin 11 of J2 104 | 105 | //------------------------------------------------------------------------------ 106 | //gfx_Set() related constants 107 | //------------------------------------------------------------------------------ 108 | #define PEN_SIZE 16 // not necessary to use (legacy mode) 109 | #define BACKGROUND_COLOUR 17 110 | #define OBJECT_COLOUR 18 // line / circle / rectangle generic colour 111 | #define CLIPPING 19 // clipping ON / OFF 112 | #define TRANSPARENT_COLOUR 20 // (only on displays with specific hware feature) 113 | #define TRANSPARENCY 21 // 0 = OFF, 1 = ON (only on displays with specific hware feature) 114 | #define FRAME_DELAY 22 // legacy mode, see pokeB(IMAGE_DELAY, n); 115 | #define SCREEN_MODE 23 // LANDSCAPE, LANDSCAPE_R, PORTRAIT, PORTRAIT_R 116 | #define OUTLINE_COLOUR 24 // if not BLACK (0) , used for outline around circles,rectangles and filled polygons 117 | #define CONTRAST 25 // for OLED,cahnge contrast, for LCD on or off only 118 | #define LINE_PATTERN 26 // used for patterned lines, 16bit value (0 = no pattern, '1's = pattern) 119 | #define COLOUR_MODE 27 // select 8 or 16 bit colour mode 120 | #define BEVEL_WIDTH 28 // button bevel width 121 | #define BEVEL_SHADOW 29 // button bevel shadow depth 122 | #define X_ORIGIN 30 // display position X offset 123 | #define Y_ORIGIN 31 // display position X offset 124 | 125 | 126 | //gfx_Get() related constants 127 | #define X_MAX 0 // current orientations screen maximum X co-ordinate 128 | #define Y_MAX 1 // current orientations screen maximum Y co-ordinate 129 | #define LEFT_POS 2 // last objects left co-ord 130 | #define TOP_POS 3 // last objects top co-ord 131 | #define RIGHT_POS 4 // last objects right co-ord 132 | #define BOTTOM_POS 5 // last objects bottom co-ord 133 | #define X_ORG 6 // display position X offset 134 | #define Y_ORG 7 // display position X offset 135 | 136 | 137 | 138 | 139 | #define SOLID 0 // PEN_SIZE 140 | #define OUTLINE 1 // PEN_SIZE 141 | #define STYLE1 2 142 | #define STYLE2 3 143 | 144 | #define LANDSCAPE 0 // SCREEN_MODE (north) 145 | #define LANDSCAPE_R 1 // SCREEN_MODE (south) 146 | #define PORTRAIT 2 // SCREEN_MODE (west) 147 | #define PORTRAIT_R 3 // SCREEN_MODE (east) 148 | 149 | #define COLOUR8 1 // COLOUR_MODE 8 bit colour mode (not supported) 150 | #define COLOUR16 0 // COLOUR_MODE 16 bit colour mode 151 | 152 | 153 | #define DOWN 0 154 | #define UP 1 155 | #define HIDE 2 156 | #define SELECT 3 157 | #define SELECT_MULTIPLE 4 158 | 159 | 160 | #define BUTTON_DOWN 0 161 | #define BUTTON_UP 1 162 | 163 | #define SLIDER_SUNKEN 0 164 | #define SLIDER_RAISED 1 165 | #define SLIDER_HIDE 2 166 | 167 | #define PROGRESSBAR_RAISED 0xFFFF 168 | #define PROGRESSBAR_SUNKEN 0xFFFE 169 | #define PROGRESSBAR_HIDE 2 170 | 171 | #define PANEL_SUNKEN 0 172 | #define PANEL_RAISED 1 173 | #define PANEL_HIDE 2 174 | 175 | 176 | //------------------------------------------------------------------------------ 177 | //txt_Set() related constants 178 | //------------------------------------------------------------------------------ 179 | #define TEXT_COLOUR 0 // text foreground colr 180 | #define TEXT_BACKGROUND 1 // text background colr 181 | #define TEXT_HIGHLIGHT 1 // text background colr 182 | #define FONT_ID 2 // default 0, else points to data statement font 183 | #define FONT_SIZE 2 // compatibility 184 | #define TEXT_WIDTH 3 // text width multiplier 185 | #define TEXT_HEIGHT 4 // text height multiplier 186 | #define TEXT_XGAP 5 // horizontal text gap (default 1) 187 | #define TEXT_YGAP 6 // vertical text gap (default 1) 188 | #define TEXT_PRINTDELAY 7 // for 'teletype' like effect when printing 189 | #define TEXT_OPACITY 8 // text mode flag, TRANSPARENT or OPAQUE 190 | #define TEXT_BOLD 9 // embolden text (auto reset) 191 | #define TEXT_ITALIC 10 // italicize text (auto reset) 192 | #define TEXT_INVERSE 11 // invert text (auto reset) 193 | #define TEXT_UNDERLINED 12 // underline text (auto reset) 194 | #define TEXT_ATTRIBUTES 13 // controls BOLD/ITALIC/INVERSE/UNDERLINE simultaneously 195 | #define TEXT_WRAP 14 // Sets the pixel position where text wrap will occur at RHS 196 | 197 | 198 | 199 | 200 | //------------------------------------------------------------------------------ 201 | //txt_Set() related arguments 202 | // NB:- FONT4 must be inherited if required, 203 | // eg #inherit "FONT4.fnt" 204 | //------------------------------------------------------------------------------ 205 | #define FONT1 0 // (same as system font) 206 | #define FONT2 1 207 | #define FONT3 2 208 | 209 | #define TRANSPARENT 0 // TEXT_OPACITY transparent text 210 | #define OPAQUE 1 // TEXT_OPACITY opaque text 211 | 212 | #define BOLD 16 // TEXT_ATTRIBUTES bold text 213 | #define ITALIC 32 // TEXT_ATTRIBUTES italic text 214 | #define INVERSE 64 // TEXT_ATTRIBUTES inverse text 215 | #define UNDERLINED 128 // TEXT_ATTRIBUTES underlined 216 | 217 | 218 | 219 | //touch_Set() related constants 220 | #define TOUCH_ENABLE 0 221 | #define TOUCH_DISABLE 1 222 | #define TOUCH_REGIONDEFAULT 2 223 | 224 | //touch_Get() related constants 225 | #define TOUCH_STATUS 0 226 | #define TOUCH_GETX 1 227 | #define TOUCH_GETY 2 228 | #define NOTOUCH 0 229 | #define TOUCH_PRESSED 1 230 | #define TOUCH_RELEASED 2 231 | #define TOUCH_MOVING 3 232 | 233 | // image control offset related constants 234 | #define IMG_COUNT 0 235 | #define IMG_ENTRYLEN 1 236 | #define IMG_MODE 2 237 | #define IMG_GCI_FILENAME 3 238 | #define IMG_DAT_FILENAME 4 239 | #define IMG_GCIFILE_HANDLE 5 240 | 241 | // image attribute flags 242 | // for img_SetAttributes(...) and img_ClearAttributes(...) 243 | #define I_ENABLED 0x8000 // bit 15, set for image enabled 244 | #define I_DARKEN 0x4000 // bit 14, display dimmed 245 | #define I_LIGHTEN 0x2000 // bit 13, display bright 246 | #define I_TOUCHED 0x1000 // bit 12, touch test result 247 | #define I_Y_LOCK 0x0800 // bit 11, stop Y movement 248 | #define I_X_LOCK 0x0400 // bit 10, stop X movement 249 | #define I_TOPMOST 0x0200 // bit 9, draw on top of other images next update (auto reset) 250 | #define I_STAYONTOP 0x0100 // bit 8, draw on top of other images always 251 | #define I_MOVIE 0x0080 // bit 7, image is a movie 252 | #define I_NOGROUP 0x0040 // bit 6, set to exclude image refresh when using img_Show(hndl, ALL); 253 | #define I_TOUCH_DISABLE 0x0020 // bit 5, set to disable touch for this image, default=1 for movie, 0 for image 254 | #define I_COLOUR16 0x0010 // bit 4, indicates 16 bit colour mode 255 | // bits 0-3 reserved 256 | 257 | 258 | #define ALL 0xFFFF // argument for img_xxx functions to update all images 259 | 260 | // image control entry offsets 261 | #define IMAGE_LOWORD 0 // WORD image address LO 262 | #define IMAGE_HIWORD 1 // WORD image address HI 263 | #define IMAGE_XPOS 2 // WORD image location X 264 | #define IMAGE_YPOS 3 // WORD image location Y 265 | #define IMAGE_WIDTH 4 // WORD image width 266 | #define IMAGE_HEIGHT 5 // WORD image height 267 | #define IMAGE_FLAGS 6 // WORD image flags 268 | #define IMAGE_DELAY 7 // WORD inter frame delay 269 | #define IMAGE_FRAMES 8 // WORD number of frames 270 | #define IMAGE_INDEX 9 // WORD current frame 271 | #define IMAGE_CLUSTER 10 // WORD image start cluster pos (for FAT16 only) 272 | #define IMAGE_SECTOR 11 // WORD image start sector in cluster pos (for FAT16 only) 273 | #define IMAGE_TAG 12 // WORD user variable #1 274 | #define IMAGE_TAG2 13 // WORD user variable #2 275 | 276 | // DISK struct offsets 277 | #define DISK_FIRST_SECT_LO 0 // DWORD address of the first sector of the FAT partition (LO word) 278 | #define DISK_FIRST_SECT_HI 1 // address of the first sector of the FAT partition (HI word) 279 | #define DISK_FAT_LO 2 // DWORD address of FAT (LO word) 280 | #define DISK_FAT_HI 3 // address of FAT (HI word) 281 | #define DISK_ROOT_LO 4 // DWORD address of root directory (LO word) 282 | #define DISK_ROOT_HI 5 // address of root directory (HI word) 283 | #define DISK_DATA_LO 6 // DWORD address of data area (LO word) 284 | #define DISK_DATA_HI 7 // address of data area (HI word) 285 | #define DISK_MAXCLUS_LO 8 // DWORD max number of clusters in partition (LO word) 286 | #define DISK_MAXCLUS_HI 9 // max number of clusters in partition (HI word) 287 | #define DISK_MAXROOT 10 // WORD max entries in root directory 288 | #define DISK_FATSIZE 11 // WORD number of sectors in FAT 289 | #define DISK_FATCOPIES 12 // WORD number of fat copies 290 | #define DISK_SECT_PER_CLUS 13 // WORD number of sectors per cluster 291 | #define DISK_TYPE 14 // WORD type of fat 292 | #define DISK_BUF 15 // WORD pointer to 512 byte info buffer 293 | 294 | 295 | 296 | 297 | // FILE struct offsets 298 | #define FILE_FIRST_CLUSTER 0 // WORD first cluster 299 | #define FILE_CURR_CLUSTER 1 // WORD current cluster in file 300 | #define FILE_CURR_SECTOR 2 // WORD sector in current cluster 301 | #define FILE_CURR_SECTOR_POS 3 // WORD position in current sector 302 | #define FILE_CURR_SECTOR_TOP 4 // WORD number bytes in current sector buffer 303 | #define FILE_SEEK_POS_LO 5 // DWORD position in the file (LO word) 304 | #define FILE_SEEK_POS_HI 6 // position in the file (HI word) 305 | #define FILE_SIZE_LO 7 // DWORD file size (LO word) 306 | #define FILE_SIZE_HI 8 // file size (HI word) 307 | #define FILE_TIME 9 // WORD last update time 308 | #define FILE_DATE 10 // WORD last update date 309 | #define FILE_NAME 11 // WORD 12 byte buffer for filename 310 | #define FILE_MODE 17 // WORD file mode 'r', 'w', 'a' 311 | #define FILE_ATTRIBUTES 18 // WORD files attributes 312 | #define FILE_PAGEFLAG 19 // WORD cache check flag 313 | #define FILE_ENTRY 20 // WORD entry position in cur directory 314 | #define FILE_DISK 21 // WORD* pointer to DISK mount media structure 315 | #define FILE_BUFFER 22 // WORD* sector buffer 316 | 317 | 318 | 319 | // timer control related constants 320 | #define TIMER04d 0 321 | #define TIMER14d 1 322 | #define TIMER24d 2 323 | #define TIMER34d 3 324 | #define TIMER44d 4 325 | #define TIMER54d 5 326 | #define TIMER64d 6 327 | #define TIMER74d 7 328 | 329 | // I2C timing related constants 330 | #define I2C_SLOW 0 331 | #define I2C_MED 1 332 | #define I2C_FAST 2 333 | 334 | 335 | // spi_Init(...) mode arguments 336 | #define SPI_SLOW 2 // 750khz 337 | #define SPI_MED 1 // 3mhz 338 | #define SPI_FAST 0 // 12mhz 339 | #define RXMODE_0 0 // receive sample pos 340 | #define RXMODE_1 1 // receive sample pos 341 | #define CKMODE_0 0 // transmit sample pos 342 | #define CKMODE_1 1 // transmit sample pos 343 | #define CKMODE_2 2 // transmit sample pos 344 | #define CKMODE_3 3 // transmit sample pos 345 | 346 | //------------------------------------------------------------------------------ 347 | // system WORD variables accesible with peekW and pokeW or pointer access 348 | // Note that the txt_Set variables (0-15) and gfx_set variables (16-31) 349 | // can also be accessed with peekW and pokeW 350 | //------------------------------------------------------------------------------ 351 | 352 | #define RANDOM_LO 32 // random number generator LO word 353 | #define RANDOM_HI 33 // random number generator LO word 354 | #define SYSTEM_TIMER_LO 34 // 1msec 32 bit free running timer LO word 355 | #define SYSTEM_TIMER_HI 35 // 1msec 32 bit free running timer HI word 356 | #define TMR0 36 // user timer0 357 | #define TMR1 37 // user timer1 358 | #define TMR2 38 // user timer2 359 | #define TMR3 39 // user timer3 (10msec resolution) 360 | #define TMR4 40 // user timer0 361 | #define TMR5 41 // user timer1 362 | #define TMR6 42 // user timer2 363 | #define TMR7 43 // user timer3 (10msec resolution) 364 | #define SYS_X_MAX 44 // display hardware X res-1 365 | #define SYS_Y_MAX 45 // display hardware Y res-1 366 | #define GFX_XMAX 46 // current display width-1 determined by portrait / landscape swapping 367 | #define GFX_YMAX 47 // current display width-1 determined by portrait / landscape swapping 368 | #define GFX_LEFT 48 // virtual left point for most recent object 369 | #define GFX_TOP 49 // virtual top point for most recent object 370 | #define GFX_RIGHT 50 // virtual right point for most recent object 371 | #define GFX_BOTTOM 51 // virtual bottom point for most recent object 372 | #define GFX_X1 52 // clipped left point for current object 373 | #define GFX_Y1 53 // clipped top point for current object 374 | #define GFX_X2 54 // clipped right point for current object 375 | #define GFX_Y2 55 // clipped bottom point for current object 376 | #define GFX_X_ORG 56 // current X origin 377 | #define GFX_Y_ORG 57 // current Y origin 378 | #define GFX_HILITE_LINE 58 // current multi line button hilite line 379 | #define GFX_LINE_COUNT 59 // count of lines in multiline button 380 | #define GFX_LAST_SELECTION 60 // last selected line 381 | #define GFX_HILIGHT_BACKGROUND 61 // multi button hilite background colour 382 | #define GFX_HILIGHT_FOREGROUND 62 // multi button hilite background colour 383 | #define GFX_BUTTON_FOREGROUND 63 // store default text colour for hilite line tracker 384 | #define GFX_BUTTON_BACKGROUND 64 // store default button colour for hilite line tracker 385 | #define GFX_BUTTON_MODE 65 // store current buttons mode 386 | #define GFX_TOOLBAR_HEIGHT 66 // height above 387 | #define GFX_STATUSBAR_HEIGHT 67 // height below 388 | #define GFX_LEFT_GUTTER_WIDTH 68 // width to left 389 | #define GFX_RIGHT_GUTTER_WIDTH 69 // width to right 390 | #define GFX_PIXEL_SHIFT 70 // pixel shift for button depress illusion (default 1) 391 | #define GFX_RECT_X1 71 // gp rect, used by multiline button to hilite required line 392 | #define GFX_RECT_Y1 72 393 | #define GFX_RECT_X2 73 394 | #define GFX_RECT_Y2 74 395 | #define GFX_THUMB_PERCENT 75 // size of slider thumb as percentage 396 | #define GFX_THUMB_BORDER_DARK 76 // darker shadow of thumb 397 | #define GFX_THUMB_BORDER_LIGHT 77 // lighter shadow of thumb 398 | #define TOUCH_XMINCAL 78 // touch calibration value 399 | #define TOUCH_YMINCAL 79 // touch calibration value 400 | #define TOUCH_XMAXCAL 80 // touch calibration value 401 | #define TOUCH_YMAXCAL 81 // touch calibration value 402 | #define IMG_WIDTH 82 // width of currently loaded image 403 | #define IMG_HEIGHT 83 // height of currently loaded image 404 | #define IMG_FRAME_DELAY 84 // 0 if image, else inter frame delay for movie 405 | #define IMG_FLAGS 85 // bit 4 determines colour mode, other bits reserved 406 | #define IMG_FRAME_COUNT 86 // count of frames in a movie 407 | #define IMG_PIXEL_COUNT_LO 87 // count of pixels in the current frame 408 | #define IMG_PIXEL_COUNT_HI 88 // count of pixels in the current frame 409 | #define IMG_CURRENT_FRAME 89 // last frame shown 410 | #define MEDIA_ADDRESS_LO 90 // uSD byte address LO 411 | #define MEDIA_ADDRESS_HI 91 // uSD byte address HI 412 | #define MEDIA_SECTOR_LO 92 // uSD sector address LO 413 | #define MEDIA_SECTOR_HI 93 // uSD sector address HI 414 | #define MEDIA_SECTOR_COUNT 94 // uSD number of bytes remaining in sector 415 | #define TEXT_XPOS 95 // text current x pixel position 416 | #define TEXT_YPOS 96 // text current y pixel position 417 | #define TEXT_MARGIN 97 // text left pixel pos for carriage return 418 | #define TXT_FONT_ID 98 // font type, 0 = system font, else pointer to user font 419 | #define TXT_FONT_MAX 99 // max number of chars in font 420 | #define TXT_FONT_OFFSET 100 // starting offset (normally 0x20) 421 | #define TXT_FONT_WIDTH 101 // current font width 422 | #define TXT_FONT_HEIGHT 102 // current font height 423 | #define GFX_TOUCH_REGION_X1 103 // touch capture region 424 | #define GFX_TOUCH_REGION_Y1 104 425 | #define GFX_TOUCH_REGION_X2 105 426 | #define GFX_TOUCH_REGION_Y2 106 427 | #define GFX_CLIP_LEFT_VAL 107 // left clipping point (set with gfx_ClipWindow(...) 428 | #define GFX_CLIP_TOP_VAL 108 // top clipping point (set with gfx_ClipWindow(...) 429 | #define GFX_CLIP_RIGHT_VAL 109 // right clipping point (set with gfx_ClipWindow(...) 430 | #define GFX_CLIP_BOTTOM_VAL 110 // bottom clipping point (set with gfx_ClipWindow(...) 431 | #define GFX_CLIP_LEFT 111 // current clip value (reads full size if clipping turned off) 432 | #define GFX_CLIP_TOP 112 // current clip value (reads full size if clipping turned off) 433 | #define GFX_CLIP_RIGHT 113 // current clip value (reads full size if clipping turned off) 434 | #define GFX_CLIP_BOTTOM 114 // current clip value (reads full size if clipping turned off) 435 | #define GRAM_PIXEL_COUNT_LO 115 // LO word of count of pixels in the set GRAM area 436 | #define GRAM_PIXEL_COUNT_HI 116 // HI word of count of pixels in the set GRAM area 437 | #define TOUCH_RAW_X 117 // 12 bit raw A2D X value from touch screen 438 | #define TOUCH_RAW_Y 118 // 12 bit raw A2D Y value from touch screen 439 | #define GFX_LAST_CHAR_WIDTH 119 // calculated char width from last call to charWidth function 440 | #define GFX_LAST_CHAR_HEIGHT 120 // calculated height from last call to charHeight function 441 | #define GFX_LAST_STR_WIDTH 121 // calculated width from last call to strWidth function 442 | #define GFX_LAST_STR_HEIGHT 122 // calculated height from last call to strHeight function 443 | 444 | //------------------------------------------------------------------------------ 445 | // FILEIO Error Code Constants 446 | //------------------------------------------------------------------------------ 447 | #define FE_OK 0 // IDE function succeeded 448 | #define FE_IDE_ERROR 1 // IDE command execution error 449 | #define FE_NOT_PRESENT 2 // CARD not present 450 | #define FE_PARTITION_TYPE 3 // WRONG partition type, not FAT16 451 | #define FE_INVALID_MBR 4 // MBR sector invalid signature 452 | #define FE_INVALID_BR 5 // Boot Record invalid signature 453 | #define FE_DISK_NOT_MNTD 6 // Media not mounted 454 | #define FE_FILE_NOT_FOUND 7 // File not found in open for read 455 | #define FE_INVALID_FILE 8 // File not open 456 | #define FE_FAT_EOF 9 // Fat attempt to read beyond EOF 457 | #define FE_EOF 10 // Reached the end of file 458 | #define FE_INVALID_CLUSTER 11 // Invalid cluster value > maxcls 459 | #define FE_DIR_FULL 12 // All root dir entry are taken 460 | #define FE_DISK_FULL 13 // All clusters in partition are taken 461 | #define FE_FILE_OVERWRITE 14 // A file with same name exist already 462 | #define FE_CANNOT_INIT 15 // Cannot init the CARD 463 | #define FE_CANNOT_READ_MBR 16 // Cannot read the MBR 464 | #define FE_MALLOC_FAILED 17 // Malloc could not allocate the FILE struct 465 | #define FE_INVALID_MODE 18 // Mode was not r.w. 466 | #define FE_FIND_ERROR 19 // Failure during FILE search 467 | #define FE_INVALID_FNAME 20 // bad filename 468 | #define FE_INVALID_MEDIA 21 // bad media 469 | #define FE_SECTOR_READ_FAIL 22 // sector read failed 470 | #define FE_SECTOR_WRITE_FAIL 23 // sector write failed 471 | 472 | /* 473 | 16 bit RGB (565) Colour Chart 474 | Original work by 4D Forum Member: skadoo 475 | */ 476 | 477 | 478 | 479 | #define ALICEBLUE 0xF7DF 480 | #define ANTIQUEWHITE 0xFF5A 481 | #define AQUA 0x07FF 482 | #define AQUAMARINE 0x7FFA 483 | #define AZURE 0xF7FF 484 | #define BEIGE 0xF7BB 485 | #define BISQUE 0xFF38 486 | #define BLACK 0x0000 487 | #define BLANCHEDALMOND 0xFF59 488 | #define BLUE 0x001F 489 | #define BLUEVIOLET 0x895C 490 | #define BROWN 0xA145 491 | #define BURLYWOOD 0xDDD0 492 | #define CADETBLUE 0x5CF4 493 | #define CHARTREUSE 0x7FE0 494 | #define CHOCOLATE 0xD343 495 | #define CORAL 0xFBEA 496 | #define CORNFLOWERBLUE 0x64BD 497 | #define CORNSILK 0xFFDB 498 | #define CRIMSON 0xD8A7 499 | #define CYAN 0x07FF 500 | #define DARKBLUE 0x0011 501 | #define DARKCYAN 0x0451 502 | #define DARKGOLDENROD 0xBC21 503 | #define DARKGRAY 0xAD55 504 | #define DARKGREEN 0x0320 505 | #define DARKKHAKI 0xBDAD 506 | #define DARKMAGENTA 0x8811 507 | #define DARKOLIVEGREEN 0x5345 508 | #define DARKORANGE 0xFC60 509 | #define DARKORCHID 0x9999 510 | #define DARKRED 0x8800 511 | #define DARKSALMON 0xECAF 512 | #define DARKSEAGREEN 0x8DF1 513 | #define DARKSLATEBLUE 0x49F1 514 | #define DARKSLATEGRAY 0x2A69 515 | #define DARKTURQUOISE 0x067A 516 | #define DARKVIOLET 0x901A 517 | #define DEEPPINK 0xF8B2 518 | #define DEEPSKYBLUE 0x05FF 519 | #define DIMGRAY 0x6B4D 520 | #define DODGERBLUE 0x1C9F 521 | #define FIREBRICK 0xB104 522 | #define FLORALWHITE 0xFFDE 523 | #define FORESTGREEN 0x2444 524 | #define FUCHSIA 0xF81F 525 | #define GAINSBORO 0xDEFB 526 | #define GHOSTWHITE 0xFFDF 527 | #define GOLD 0xFEA0 528 | #define GOLDENROD 0xDD24 529 | #define GRAY 0x8410 530 | #define GREEN 0x0400 531 | #define GREENYELLOW 0xAFE5 532 | #define HONEYDEW 0xF7FE 533 | #define HOTPINK 0xFB56 534 | #define INDIANRED 0xCAEB 535 | #define INDIGO 0x4810 536 | #define IVORY 0xFFFE 537 | #define KHAKI 0xF731 538 | #define LAVENDER 0xE73F 539 | #define LAVENDERBLUSH 0xFF9E 540 | #define LAWNGREEN 0x7FE0 541 | #define LEMONCHIFFON 0xFFD9 542 | #define LIGHTBLUE 0xAEDC 543 | #define LIGHTCORAL 0xF410 544 | #define LIGHTCYAN 0xE7FF 545 | #define LIGHTGOLD 0xFFDA 546 | #define LIGHTGREEN 0x9772 547 | #define LIGHTGREY 0xD69A 548 | #define LIGHTPINK 0xFDB8 549 | #define LIGHTSALMON 0xFD0F 550 | #define LIGHTSEAGREEN 0x2595 551 | #define LIGHTSKYBLUE 0x867F 552 | #define LIGHTSLATEGRAY 0x7453 553 | #define LIGHTSTEELBLUE 0xB63B 554 | #define LIGHTYELLOW 0xFFFC 555 | #define LIME 0x07E0 556 | #define LIMEGREEN 0x3666 557 | #define LINEN 0xFF9C 558 | #define MAGENTA 0xF81F 559 | #define MAROON 0x8000 560 | #define MEDIUMAQUAMARINE 0x6675 561 | #define MEDIUMBLUE 0x0019 562 | #define MEDIUMORCHID 0xBABA 563 | #define MEDIUMPURPLE 0x939B 564 | #define MEDIUMSEAGREEN 0x3D8E 565 | #define MEDIUMSLATEBLUE 0x7B5D 566 | #define MEDIUMSPRINGGREEN 0x07D3 567 | #define MEDIUMTURQUOISE 0x4E99 568 | #define MEDIUMVIOLETRED 0xC0B0 569 | #define MIDNIGHTBLUE 0x18CE 570 | #define MINTCREAM 0xF7FF 571 | #define MISTYROSE 0xFF3C 572 | #define MOCCASIN 0xFF36 573 | #define NAVAJOWHITE 0xFEF5 574 | #define NAVY 0x0010 575 | #define OLDLACE 0xFFBC 576 | #define OLIVE 0x8400 577 | #define OLIVEDRAB 0x6C64 578 | #define ORANGE 0xFD20 579 | #define ORANGERED 0xFA20 580 | #define ORCHID 0xDB9A 581 | #define PALEGOLDENROD 0xEF55 582 | #define PALEGREEN 0x9FD3 583 | #define PALETURQUOISE 0xAF7D 584 | #define PALEVIOLETRED 0xDB92 585 | #define PAPAYAWHIP 0xFF7A 586 | #define PEACHPUFF 0xFED7 587 | #define PERU 0xCC27 588 | #define PINK 0xFE19 589 | #define PLUM 0xDD1B 590 | #define POWDERBLUE 0xB71C 591 | #define PURPLE 0x8010 592 | #define RED 0xF800 593 | #define ROSYBROWN 0xBC71 594 | #define ROYALBLUE 0x435C 595 | #define SADDLEBROWN 0x8A22 596 | #define SALMON 0xFC0E 597 | #define SANDYBROWN 0xF52C 598 | #define SEAGREEN 0x2C4A 599 | #define SEASHELL 0xFFBD 600 | #define SIENNA 0xA285 601 | #define SILVER 0xC618 602 | #define SKYBLUE 0x867D 603 | #define SLATEBLUE 0x6AD9 604 | #define SLATEGRAY 0x7412 605 | #define SNOW 0xFFDF 606 | #define SPRINGGREEN 0x07EF 607 | #define STEELBLUE 0x4416 608 | #define TAN 0xD5B1 609 | #define TEAL 0x0410 610 | #define THISTLE 0xDDFB 611 | #define TOMATO 0xFB08 612 | #define TURQUOISE 0x471A 613 | #define VIOLET 0xEC1D 614 | #define WHEAT 0xF6F6 615 | #define WHITE 0xFFFF 616 | #define WHITESMOKE 0xF7BE 617 | #define YELLOW 0xFFE0 618 | #define YELLOWGREEN 0x9E66 619 | 620 | #define Err4D_OK 0 621 | #define Err4D_Timeout 1 622 | #define Err4D_NAK 2 // other than ACK received 623 | 624 | #define t4DWordArray word * 625 | #define t4DByteArray char * 626 | #define t4DSector char * 627 | 628 | #define F_charheight 29 629 | #define F_charwidth 30 630 | #define F_bus_In -45 631 | #define F_bus_Out -46 632 | #define F_bus_Read -49 633 | #define F_bus_Set -47 634 | #define F_bus_Write -48 635 | #define F_file_Close -232 636 | #define F_file_Count 1 637 | #define F_file_Dir 2 638 | #define F_file_Erase 3 639 | #define F_file_Error -225 640 | #define F_file_Exec 4 641 | #define F_file_Exists 5 642 | #define F_file_FindFirst 6 643 | #define F_file_FindNext -229 644 | #define F_file_GetC -242 645 | #define F_file_GetS 7 646 | #define F_file_GetW -244 647 | #define F_file_Image -239 648 | #define F_file_Index -235 649 | #define F_file_LoadFunction 8 650 | #define F_file_LoadImageControl 9 651 | #define F_file_Mount -253 652 | #define F_file_Open 10 653 | #define F_file_PlayWAV 11 654 | #define F_file_PutC 31 655 | #define F_file_PutS 32 656 | #define F_file_PutW -243 657 | #define F_file_Read 12 658 | #define F_file_Rewind -248 659 | #define F_file_Run 13 660 | #define F_file_ScreenCapture -240 661 | #define F_file_Seek -234 662 | #define F_file_Size 14 663 | #define F_file_Tell 15 664 | #define F_file_Unmount -254 665 | #define F_file_Write 16 666 | #define F_gfx_BevelShadow -104 667 | #define F_gfx_BevelWidth -103 668 | #define F_gfx_BGcolour -92 669 | #define F_gfx_Button 17 670 | #define F_gfx_ChangeColour -76 671 | #define F_gfx_Circle -61 672 | #define F_gfx_CircleFilled -62 673 | #define F_gfx_Clipping -94 674 | #define F_gfx_ClipWindow -75 675 | #define F_gfx_Cls -51 676 | #define F_gfx_Contrast -100 677 | #define F_gfx_Ellipse -78 678 | #define F_gfx_EllipseFilled -79 679 | #define F_gfx_FrameDelay -97 680 | #define F_gfx_Get -90 681 | #define F_gfx_GetPixel -64 682 | #define F_gfx_Line -56 683 | #define F_gfx_LinePattern -101 684 | #define F_gfx_LineTo -54 685 | #define F_gfx_MoveTo -52 686 | #define F_gfx_Orbit 18 687 | #define F_gfx_OutlineColour -99 688 | #define F_gfx_Panel -81 689 | //#define F_gfx_PenSize -91 690 | #define F_gfx_Polygon 19 691 | #define F_gfx_PolygonFilled 20 692 | #define F_gfx_Polyline 21 693 | #define F_gfx_PutPixel -63 694 | #define F_gfx_Rectangle -59 695 | #define F_gfx_RectangleFilled -60 696 | #define F_gfx_ScreenCopyPaste -83 697 | #define F_gfx_ScreenMode -98 698 | #define F_gfx_Set -50 699 | #define F_gfx_SetClipRegion -77 700 | #define F_gfx_Slider -82 701 | #define F_gfx_Transparency -96 702 | #define F_gfx_TransparentColour -95 703 | #define F_gfx_Triangle -65 704 | #define F_gfx_TriangleFilled -87 705 | #define F_img_ClearAttributes -187 706 | #define F_img_Darken -181 707 | #define F_img_Disable -180 708 | #define F_img_Enable -179 709 | #define F_img_GetWord -184 710 | #define F_img_Lighten -182 711 | #define F_img_SetAttributes -186 712 | #define F_img_SetPosition -178 713 | #define F_img_SetWord -183 714 | #define F_img_Show -185 715 | #define F_img_Touched -188 716 | #define F_media_Flush -118 717 | #define F_media_Image -117 718 | #define F_media_Init -119 719 | #define F_media_RdSector 22 720 | #define F_media_ReadByte -113 721 | #define F_media_ReadWord -114 722 | #define F_media_SetAdd -109 723 | #define F_media_SetSector -110 724 | #define F_media_Video -107 725 | #define F_media_VideoFrame -108 726 | #define F_media_WriteByte -115 727 | #define F_media_WriteWord -116 728 | #define F_media_WrSector 23 729 | #define F_mem_Free -220 730 | #define F_mem_Heap -221 731 | #define F_peekM 39 732 | #define F_pin_HI -42 733 | #define F_pin_LO -43 734 | #define F_pin_Read -44 735 | #define F_pin_Set -41 736 | #define F_pokeM 40 737 | #define F_putCH -2 738 | #define F_putstr 24 739 | #define F_snd_BufSize -258 740 | #define F_snd_Continue -261 741 | #define F_snd_Pause -260 742 | #define F_snd_Pitch -257 743 | #define F_snd_Playing -262 744 | #define F_snd_Stop -259 745 | #define F_snd_Volume -256 746 | #define F_sys_Sleep -197 747 | #define F_touch_DetectRegion -199 748 | #define F_touch_Get -201 749 | #define F_touch_Set -200 750 | #define F_txt_Attributes -38 751 | #define F_txt_BGcolour -26 752 | #define F_txt_Bold -34 753 | #define F_txt_FGcolour -25 754 | #define F_txt_FontID -27 755 | #define F_txt_Height -29 756 | #define F_txt_Inverse -36 757 | #define F_txt_Italic -35 758 | #define F_txt_MoveCursor -23 759 | #define F_txt_Opacity -33 760 | #define F_txt_Set -24 761 | #define F_txt_Underline -37 762 | #define F_txt_Width -28 763 | #define F_txt_Wrap -39 764 | #define F_txt_Xgap -30 765 | #define F_txt_Ygap -31 766 | #define F_file_CallFunction 25 767 | #define F_sys_GetModel 26 768 | #define F_sys_GetVersion 27 769 | #define F_sys_GetPmmC 28 770 | #define F_writeString 33 771 | #define F_readString 34 772 | #define F_blitComtoDisplay 35 773 | #define F_file_FindFirstRet 36 774 | #define F_file_FindNextRet 37 775 | #define F_setbaudWait 38 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /examples/BigDemo/BigDemo.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************************************/ 2 | /* */ 3 | /* 4D Serial Sample */ 4 | /* */ 5 | /* Date: 4 December 2012 (updated 17 October 2014) */ 6 | /* */ 7 | /* Description: Demonstrates Pretty much every 4D Serial command. */ 8 | /* This has been tested on an Arduino Duemilanove ATmega328 using Arduino */ 9 | /* 1.0.2 */ 10 | /* This program, by default, uses the hardware serial on pins 0 and 1 and */ 11 | /* thus the 5 pin connector on the 4D Arduino Adapter, or the 4Display */ 12 | /* Shield must be unplugged before loading your sketch and plugged back in */ 13 | /* after the error callback is called (i.e. the LED is flashing), then */ 14 | /* reset the Arduino using the Reset button (otherwise you will get a */ 15 | /* message like "avrdude: stk500_getsync(): not in sync: resp=0xe0") */ 16 | /* */ 17 | /* The library also supports other hardware serial ports, for the boards */ 18 | /* that support them, as well as software serial. */ 19 | /* */ 20 | /* Define the serial port to use here, if using software serial set it to */ 21 | /* something like SerialS. */ 22 | /* */ 23 | #define DisplaySerial Serial 24 | /* */ 25 | /* To use SoftwareSerial uncomment the following and set the pins you are */ 26 | /* using correctly */ 27 | //#include 28 | //SoftwareSerial DisplaySerial(2,3) ; // pin 2 = TX of display, pin3 = RX 29 | /* */ 30 | /* If you are not using hardware serial on pins 0 and 1 you can use this */ 31 | /* hardware port for logging messages. To do this uncomment the following */ 32 | //#define LOG_MESSAGES 33 | /* */ 34 | /* Error Callback In order to drastically reduce the amount of error checking you need */ 35 | /* to do a callback exists to perform 'standard' error handling when an */ 36 | /* occurs. If you want to do your own handling set Callback4D to NULL */ 37 | /* otherwise set it to the address of the error routine */ 38 | /* */ 39 | /* Sketch Size! If you are logging messages, then you may exceed the maximum sketch */ 40 | /* size for some of the smaller boards, you can comment out TEST_USD to */ 41 | /* exclude tests that require a uSD card to run and/or TEST_OTHER to */ 42 | /* exclude tests that do not require a uSD card to run. */ 43 | /* */ 44 | #define TEST_USD 45 | #define TEST_OTHER 46 | /* */ 47 | /* The following files are needed on the uSD to complete all tests. Their */ 48 | /* relative location (from C:\Users\Public\Documents\4D Labs) is shown */ 49 | /* gfx2demo.gci resources\GC Files */ 50 | /* gfx2demo.dat resources\GC Files */ 51 | /* KBFunc.4fn Picaso ViSi */ 52 | /* KBFunc.gci Picaso ViSi */ 53 | /* KBFunc.dat Picaso ViSi */ 54 | /* Space.wav Picaso ViSi Genie\SoundPlayer.ImgData */ 55 | /* */ 56 | /*********************************************************************************************/ 57 | 58 | #ifdef LOG_MESSAGES 59 | #define HWLOGGING Serial 60 | #else 61 | #define HWLOGGING if (1) {} else Serial 62 | #endif 63 | 64 | #include "Picaso_Serial_4DLib.h" 65 | #include "BigDemo.h" 66 | #include "Picaso_Const4D.h" 67 | 68 | // Use this if using HardwareSerial or SoftwareSerial 69 | Picaso_Serial_4DLib Display(&DisplaySerial); 70 | 71 | // Use this block if using a different Serial class 72 | // 73 | // void customSetBaudRate(unsigned long newRate) { 74 | // DisplaySerial.flush(); 75 | // DisplaySerial.end(); 76 | // DisplaySerial.begin(newRate); 77 | // delay(50) ; // Display sleeps for 100 78 | // DisplaySerial.flush(); 79 | // } 80 | // Picaso_Serial_4DLib Display(&DisplaySerial, customSetBaudRate); 81 | 82 | const char *atoz = {"abcdefghijklmnopqrstuvwxyz"} ; 83 | 84 | // globals for this sketch 85 | int fFATtests ; 86 | int fmediatests ; 87 | int fimgtests ; 88 | int ftouchtests ; 89 | int floadtests ; 90 | int fsoundtests ; 91 | unsigned long rawbase ; 92 | 93 | int trymount(void) 94 | { 95 | #define retries 15 96 | int i ; 97 | int j ; 98 | i = Display.file_Mount() ; 99 | j = 0 ; 100 | if (!i) 101 | { 102 | Display.putstr("Please insert uSD card\n") ; 103 | while ( (!i) 104 | && (j < retries) ) 105 | { 106 | Display.putstr(".") ; 107 | i = Display.file_Mount() ; 108 | j++ ; 109 | } 110 | Display.putstr("\n") ; 111 | } 112 | if (j == retries) 113 | return false ; 114 | else 115 | return true ; 116 | } 117 | 118 | int RAWPartitionbase(unsigned long * rawbaseo) 119 | { 120 | unsigned char sector[512] ; 121 | int rawsize ; 122 | int FAT ; 123 | int RAW ; 124 | int result = false ; 125 | Display.media_SetAdd(0, 0) ; // so we test this, could use SetSector instead 126 | if (!Display.media_RdSector((char *)sector)) 127 | HWLOGGING.println(F("read sector failed")) ; 128 | else 129 | { 130 | *rawbaseo = 0 ; 131 | RAW = false ; 132 | FAT = false ; 133 | if ( (sector[511] == 0xaa) 134 | && (sector[510] == 0x55) ) 135 | { // possible partition table 136 | if ( ( (sector[446] == 0) 137 | || (sector[446] == 0x80) ) 138 | && ( (sector[462] == 0) 139 | || (sector[462] == 0x80) ) 140 | && ( (sector[478] == 0) 141 | || (sector[478] == 0x80) ) 142 | && ( (sector[494] == 0) 143 | || (sector[494] == 0x80) ) ) 144 | { 145 | if ( (sector[450] == 0x04) 146 | || (sector[450] == 0x06) 147 | || (sector[450] == 0x0E) ) 148 | FAT = true ; 149 | if (sector[466] == 0xDA) 150 | { 151 | *rawbaseo = (unsigned)sector[470] + (unsigned)(sector[471] << 8) + (unsigned)(sector[472] << 16) + (unsigned)(sector[473] << 24) ; 152 | rawsize = (unsigned)sector[474] + (unsigned)(sector[475] << 8) + (unsigned)(sector[476] << 16) + (unsigned)(sector[477] << 24) ; 153 | result = true ; 154 | RAW = true ; 155 | } 156 | } 157 | else 158 | { 159 | if (sector[0] == 0xEB) // jmp instruction 160 | FAT = true ; 161 | else 162 | RAW = true ; // but no really possible as we couldn't have gotten this far in this sketch 163 | } 164 | } 165 | else 166 | RAW = true ; // but no really possible as we couldn't have gotten this far in this sketch 167 | } 168 | return result ; 169 | } 170 | 171 | void Function_Tests (void) 172 | { 173 | int i, j ; 174 | int k ; 175 | int l ; 176 | int m ; 177 | word handle, h1, h2 ; 178 | word parms[20]; 179 | char wks1[255] ; 180 | char wks2[255] ; 181 | char wks3[255] ; 182 | Display.gfx_Cls() ; 183 | Display.putstr("file_Run, file_Exec and\nfile_LoadFunction Tests") ; 184 | HWLOGGING.println(F("file_Run, file_Exec and file_LoadFunction Tests")) ; 185 | j = Display.mem_Heap() ; 186 | handle = Display.file_LoadFunction(functest) ; 187 | 188 | h1 = Display.writeString(0, "Please enter your name") ; // prompts string 189 | h2 = Display.writeString(h1, "") ; // result string, must be max length if following strings are to be 'kept' 190 | HWLOGGING.print(F("String Handles")) ; 191 | HWLOGGING.print(h1) ; 192 | HWLOGGING.print(F(", ")) ; 193 | HWLOGGING.println(h2) ; 194 | parms[0] = h1 ; // prompt string 195 | parms[1] = h2 ; // result string 196 | parms[2] = 20 ; 197 | parms[3] = 1 ; // 1 = save screen, 0 = don't save screen 198 | Display.TimeLimit4D = 5000000 ; 199 | 200 | i = Display.file_CallFunction(handle, 4, parms) ; // calls a function 201 | HWLOGGING.print(F("You typed ")) ; 202 | HWLOGGING.print(i) ; 203 | HWLOGGING.print(F(" characters ")) ; 204 | Display.readString(h2, wks1) ; // read string immediately as it will be overwritten 'soon' 205 | // HWLOGGING.print((unsigned char)&wks1) ; 206 | HWLOGGING.println(wks1) ; 207 | k = Display.mem_Heap() ; 208 | Display.mem_Free(handle) ; 209 | l = Display.mem_Heap() ; 210 | delay(5000) ; // give time to read the 'restored' screen 211 | 212 | h1 = Display.writeString(0, "Please type anything") ; // prompts string 213 | h2 = Display.writeString(h1, "") ; // result string, must be max length if following strings are to be 'kept' 214 | parms[0] = h1 ; // prompt string 215 | parms[1] = h2 ; // result string 216 | parms[2] = 20 ; 217 | parms[3] = 0 ; // 1 = save screen, 0 = don't save screen 218 | i = Display.file_Exec(functest, 4, parms) ; 219 | Display.readString(h2, wks2) ; // read string immediately as it will be overwritten 'soon' 220 | Display.gfx_Cls() ; 221 | 222 | h1 = Display.writeString(0, "Please some more") ; // prompts string 223 | h2 = Display.writeString(h1, "") ; // result string, must be max length if following strings are to be 'kept' 224 | parms[0] = h1 ; // prompt string 225 | parms[1] = h2 ; // result string 226 | parms[2] = 20 ; 227 | parms[3] = 0 ; // 1 = save screen, 0 = don't save screen 228 | i = Display.file_Run(functest, 4, parms) ; 229 | Display.readString(h2, wks3) ; // read string immediately as it will be overwritten 'soon' 230 | Display.gfx_Cls() ; 231 | m = Display.mem_Heap() ; 232 | HWLOGGING.print(F("Memfree before loadfunction = ")) ; 233 | HWLOGGING.println(j) ; 234 | HWLOGGING.print(F("Memfree after loadfunction = ")) ; 235 | HWLOGGING.println(k) ; 236 | HWLOGGING.print(F("Memfree after free = ")) ; 237 | HWLOGGING.println(l) ; 238 | HWLOGGING.print(F("Memfree at end = ")) ; 239 | HWLOGGING.println(m) ; 240 | HWLOGGING.println(F("You typed")) ; 241 | HWLOGGING.println(wks1) ; 242 | HWLOGGING.println(wks2) ; 243 | HWLOGGING.println(wks3) ; 244 | Display.putstr("You typed\n") ; 245 | Display.putstr(wks1) ; 246 | Display.putstr("\n") ; 247 | Display.putstr(wks2) ; 248 | Display.putstr("\n") ; 249 | Display.putstr(wks3) ; 250 | Display.TimeLimit4D = 2000 ; 251 | } 252 | 253 | void gfx_Part1(void) 254 | { 255 | int i ; 256 | Display.gfx_BGcolour(LIGHTGOLD) ; // to check CLS works with different bg color 257 | Display.gfx_Cls() ; 258 | Display.txt_BGcolour(LIGHTGOLD) ; // to ensure text goesn look odd 259 | Display.txt_FGcolour(RED) ; 260 | Display.putstr("Display.gfx_A to Display.gfx_L") ; 261 | HWLOGGING.println(F("Display.gfx_A to Display.gfx_L")) ; 262 | Display.txt_FGcolour(LIME) ; // reset 263 | Display.gfx_BevelShadow(1) ; // make it really dark 264 | Display.gfx_BevelWidth(6) ; // make the button bigger by increasing the bevel size 265 | for (i = 1; i <= 10; i++) 266 | { 267 | Display.gfx_Button(ON, 120, 50, YELLOW, PURPLE, FONT3, 1, 1, "Test Button") ; 268 | delay(100) ; 269 | Display.gfx_Button(OFF, 120, 50, YELLOW, PURPLE, FONT3, 1, 1, "Test Button") ; 270 | delay(100) ; 271 | } 272 | Display.gfx_BevelShadow(3) ; // back to default 273 | Display.gfx_ChangeColour(LIME, WHITE) ; 274 | Display.gfx_Circle(30, 30, 10, BLUE) ; 275 | Display.gfx_CircleFilled(130, 30, 10, BLUE) ; 276 | Display.gfx_Rectangle(60, 60, 100, 100, RED) ; // draw a rectange to show where we are clipping 277 | Display.gfx_ClipWindow(60, 60, 100, 100) ; 278 | Display.gfx_Clipping(ON) ; // turn clipping on but just use it for text 279 | Display.gfx_MoveTo(40, 80) ; 280 | Display.putstr("1234567890asdfghjkl") ; // this is clipped 281 | Display.gfx_Clipping(OFF) ; 282 | delay(1000) ; 283 | HWLOGGING.println(F("Display off")) ; 284 | Display.gfx_Contrast(0) ; 285 | delay(1000) ; 286 | Display.gfx_Contrast(15) ; 287 | HWLOGGING.println(F("Display on")) ; 288 | Display.gfx_Ellipse(100, 230, 50, 30, RED) ; 289 | Display.gfx_EllipseFilled(100, 300, 50, 30, AQUA) ; 290 | Display.gfx_FrameDelay(6) ; 291 | HWLOGGING.print(F("X Res= ")) ; 292 | HWLOGGING.print(Display.gfx_Get(X_MAX) + 1) ; 293 | HWLOGGING.print(F(" Y Res= ")) ; 294 | HWLOGGING.println(Display.gfx_Get(Y_MAX) + 1) ; 295 | HWLOGGING.print(F("Pixel at 0,30 is ")) ; 296 | HWLOGGING.println(Display.gfx_GetPixel(0, 30), HEX) ; 297 | Display.gfx_Line(0, 0, 100, 200, BLUE) ; 298 | Display.gfx_LinePattern(0x00aa) ; 299 | Display.gfx_Set(OBJECT_COLOUR, WHITE); 300 | Display.gfx_LineTo(239, 319) ; 301 | Display.gfx_LinePattern(0) ; // reser 302 | Display.gfx_BGcolour(BLACK) ; // reset 303 | Display.txt_BGcolour(BLACK) ; // reset 304 | } 305 | 306 | void gfx_Part2(void) 307 | { 308 | int i ; 309 | int k ; 310 | int l ; 311 | word orbitx ; 312 | word orbity ; 313 | word vx[20] ; // : array[0..19] of word ; 314 | word vy[20] ; // : array[0..19] of word ; 315 | Display.gfx_Cls() ; 316 | Display.putstr("Display.gfx_M to Display.gfx_T") ; 317 | HWLOGGING.println(F("Display.gfx_M to Display.gfx_T")) ; 318 | k = 180 ; 319 | l = 80 ; 320 | Display.gfx_MoveTo(k, l); 321 | Display.gfx_CircleFilled(k, l, 5, BLUE) ; 322 | i = -90; // 12 o'clock position 323 | while (i < 270) 324 | { 325 | Display.gfx_Orbit(i, 30, &orbitx, &orbity); 326 | k = 3; 327 | if ((i % 90) == 0 ) 328 | k = 5; 329 | Display.gfx_Circle(orbitx , orbity, k, BLUE); 330 | i += 30; // each 30 degreees 331 | } 332 | 333 | Display.gfx_OutlineColour(YELLOW) ; 334 | Display.gfx_Panel(PANEL_RAISED, 140, 0, 190, 20, LIME) ; 335 | Display.gfx_OutlineColour(0) ; // turn outline off 336 | vx[0] = 36; vy[0] = 110; 337 | vx[1] = 36; vy[1] = 80; 338 | vx[2] = 50; vy[2] = 80; 339 | vx[3] = 50; vy[3] = 110; 340 | vx[4] = 76; vy[4] = 104; 341 | vx[5] = 85; vy[5] = 80; 342 | vx[6] = 94; vy[6] = 104; 343 | vx[7] = 76; vy[7] = 70; 344 | vx[8] = 85; vy[8] = 76; 345 | vx[9] = 94; vy[9] = 70; 346 | vx[10] = 110; vy[10] = 66; 347 | vx[11] = 110; vy[11] = 80; 348 | vx[12] = 100; vy[12] = 90; 349 | vx[13] = 120; vy[13] = 90; 350 | vx[14] = 110; vy[14] = 80; 351 | vx[15] = 101; vy[15] = 70; 352 | vx[16] = 110; vy[16] = 76; 353 | vx[17] = 119; vy[17] = 70; 354 | // house 355 | Display.gfx_Rectangle(6, 50, 66, 110, RED); // frame 356 | Display.gfx_Triangle(6, 50, 36, 9, 66, 50, YELLOW); // roof 357 | Display.gfx_Polyline(4, &vx[0], &vy[0], CYAN); // door 358 | // man 359 | Display.gfx_Circle(85, 56, 10, BLUE); // head 360 | Display.gfx_Line(85, 66, 85, 80, BLUE); // body 361 | Display.gfx_Polyline(3, &vx[4], &vy[4], CYAN); // legs 362 | Display.gfx_Polyline(3, &vx[7], &vy[7], BLUE); // arms 363 | // woman 364 | Display.gfx_Circle(110, 56, 10, PINK); // head 365 | Display.gfx_Polyline(5, &vx[10], &vy[10], BROWN); // dress 366 | Display.gfx_Line(104, 104, 106, 90, PINK); // left arm 367 | Display.gfx_Line(112, 90, 116, 104, PINK); // right arm 368 | Display.gfx_Polyline(3, &vx[15], &vy[15], SALMON); // dress 369 | 370 | vx[0] = 10; vy[0] = 130; 371 | vx[1] = 35; vy[1] = 125; 372 | vx[2] = 80; vy[2] = 130; 373 | vx[3] = 60; vy[3] = 145; 374 | vx[4] = 80; vy[4] = 160; 375 | vx[5] = 35; vy[5] = 170; 376 | vx[6] = 10; vy[6] = 160; 377 | Display.gfx_Polygon(7, vx, vy, RED); 378 | 379 | vx[0] = 110; vy[0] = 130; 380 | vx[1] = 135; vy[1] = 125; 381 | vx[2] = 180; vy[2] = 130; 382 | vx[3] = 160; vy[3] = 145; 383 | vx[4] = 180; vy[4] = 160; 384 | vx[5] = 135; vy[5] = 170; 385 | vx[6] = 110; vy[6] = 160; 386 | Display.gfx_PolygonFilled(7, vx, vy, RED); 387 | 388 | Display.gfx_PutPixel(40, 94, LIME) ; // door knob 389 | Display.gfx_Rectangle(0, 180, 10, 200, AQUA) ; 390 | Display.gfx_RectangleFilled(20, 180, 40, 200, ORANGE) ; 391 | Display.gfx_ScreenCopyPaste(0, 0, 0, 280, 40, 40) ; 392 | Display.gfx_ScreenMode(LANDSCAPE) ; 393 | //Display.gfx_Set(CLIPPING, ON) ; 394 | //Display.gfx_SetClipRegion() ; 395 | Display.gfx_Slider(SLIDER_RAISED, 210, 100, 250, 10, BLUE, 100, 50) ; // coordinates are different because we are in landscape mode 396 | Display.gfx_ScreenMode(PORTRAIT) ; 397 | Display.gfx_Transparency(ON) ; 398 | Display.gfx_TransparentColour(YELLOW) ; // how do we 'test' this? 399 | Display.gfx_Triangle(6, 250, 36, 209, 66, 250, YELLOW); 400 | Display.gfx_TriangleFilled(110, 210, 130, 210, 120, 230, CYAN); 401 | } 402 | 403 | void text_Tests(void) 404 | { 405 | Display.gfx_Cls() ; 406 | HWLOGGING.println(F("Text Tests")) ; 407 | Display.putstr("Text Tests") ; 408 | 409 | Display.txt_Attributes(BOLD + INVERSE + ITALIC + UNDERLINED) ; 410 | Display.txt_Xgap(3) ; 411 | Display.txt_Ygap(3) ; 412 | Display.txt_BGcolour(YELLOW) ; 413 | Display.txt_FGcolour(WHITE) ; 414 | Display.txt_FontID(FONT3) ; 415 | Display.txt_MoveCursor(5, 0) ; 416 | Display.putstr("Hello There") ; 417 | 418 | Display.txt_MoveCursor(6, 2) ; 419 | Display.txt_Height(2) ; 420 | Display.txt_Width(2) ; 421 | Display.txt_Inverse(OFF) ; 422 | Display.txt_Italic(OFF) ; 423 | Display.txt_Opacity(TRANSPARENT) ; 424 | Display.txt_Set(TEXT_COLOUR, LIME) ; 425 | Display.txt_Underline(ON) ; 426 | Display.txt_Bold(OFF) ; 427 | Display.txt_Wrap(88) ; 428 | Display.putstr("Hello There") ; 429 | Display.txt_Height(1) ; 430 | Display.txt_Width(1) ; 431 | Display.txt_Wrap(0) ; // reset 432 | Display.putCH('z') ; 433 | HWLOGGING.print(F("Char height= ")) ; 434 | HWLOGGING.print(Display.charheight('w')) ; 435 | HWLOGGING.print(F(" Width= ")) ; 436 | HWLOGGING.println(Display.charwidth('w')) ; 437 | Display.txt_BGcolour(BLACK) ; 438 | Display.txt_FGcolour(LIME) ; 439 | Display.txt_FontID(FONT3) ; 440 | Display.txt_MoveCursor(0, 0) ; // reset 441 | } 442 | 443 | void FAT_Tests(void) 444 | { 445 | int i ; 446 | int j ; 447 | int k , handle; 448 | word w1, w2 ; 449 | char wks[512] ; 450 | char bytes[20] ; 451 | datar data ; 452 | Display.gfx_Cls() ; 453 | HWLOGGING.println(F("FAT Tests")) ; 454 | Display.putstr("FAT Tests\n") ; 455 | HWLOGGING.print(F("File Error= ")) ; 456 | HWLOGGING.println(Display.file_Error()) ; 457 | HWLOGGING.print(F("uSD has ")) ; 458 | HWLOGGING.print(Display.file_Count("*.*")) ; 459 | HWLOGGING.println(F(" Files")) ; 460 | Display.file_Dir("*.dat") ; // should this get returned!? FindFirst and next certainly should, both need to be manual as they need "to(buffer)" 461 | 462 | if (Display.file_Exists(testdat)) 463 | Display.file_Erase(testdat) ; 464 | handle = Display.file_Open(testdat, 'w') ; 465 | HWLOGGING.print(F("Handle= ")) ; 466 | HWLOGGING.println(handle) ; 467 | // write some stuff to uSD 468 | Display.file_PutC('a', handle) ; 469 | Display.file_PutW(1234, handle) ; 470 | Display.file_PutS("This is a Test", handle) ; 471 | Display.file_Close(handle) ; 472 | 473 | handle = Display.file_Open(testdat, 'r') ; 474 | HWLOGGING.print(F("Handle= ")) ; 475 | HWLOGGING.println(handle) ; 476 | // read it back and dump to screen 477 | HWLOGGING.println(Display.file_GetC(handle)) ; 478 | HWLOGGING.println(Display.file_GetW(handle)) ; 479 | i = Display.file_GetS(wks, 100, handle) ; 480 | HWLOGGING.println(F("Length=")) ; 481 | HWLOGGING.print(i) ; 482 | HWLOGGING.print(F(" String=")) ; 483 | HWLOGGING.println(wks) ; 484 | Display.file_Rewind(handle) ; 485 | i = Display.file_Read(bytes, 10, handle) ; 486 | HWLOGGING.print(F("Bytes read= ")) ; 487 | HWLOGGING.print(i) ; 488 | HWLOGGING.print(F(" Data=")) ; 489 | for (j = 0; j <= i - 1; j++) 490 | HWLOGGING.print(bytes[j], HEX) ; 491 | i = Display.file_Tell(handle, &w1, &w2) ; 492 | HWLOGGING.print(F("\nFile pointer= ")) ; 493 | HWLOGGING.println((w1 << 16) + w2) ; 494 | i = Display.file_Size(handle, &w1, &w2) ; 495 | HWLOGGING.print(F("File size=")) ; 496 | HWLOGGING.println((w1 << 16) + w2) ; 497 | 498 | Display.file_Close(handle) ; 499 | Display.file_Erase(testdat) ; 500 | 501 | handle = Display.file_Open(testdat, 'w') ; 502 | HWLOGGING.print(F("Handle= ")) ; 503 | HWLOGGING.println(handle) ; 504 | for (i = 1; i <= 50; i++) 505 | { 506 | data.recnum = i ; 507 | k = i % 20 ; 508 | for (j = 0; j <= 4; j++) 509 | { 510 | data.values[j] = atoz[k + j] ; 511 | data.idx = atoz[rand() % 27] ; 512 | } 513 | Display.file_Write(sizeof(data), (char *)&data, handle) ; 514 | } 515 | Display.file_Close(handle) ; 516 | handle = Display.file_Open(testdat, 'r') ; 517 | Display.file_Index(handle, sizeof(data) >> 16, sizeof(data) & 0xFFFF, 5) ; 518 | i = Display.file_Read((char *)&data, sizeof(data), handle) ; 519 | HWLOGGING.print(data.recnum) ; 520 | HWLOGGING.print(data.values[0]) ; 521 | HWLOGGING.print(data.values[1]) ; 522 | HWLOGGING.print(data.values[2]) ; 523 | HWLOGGING.print(data.values[3]) ; 524 | HWLOGGING.print(data.values[4]) ; 525 | HWLOGGING.println(data.idx) ; 526 | Display.file_Seek(handle, 0, 10 * sizeof(data)) ; 527 | i = Display.file_Read((char *)&data, sizeof(data), handle) ; 528 | HWLOGGING.print(data.recnum) ; 529 | HWLOGGING.print(data.values[0]) ; 530 | HWLOGGING.print(data.values[1]) ; 531 | HWLOGGING.print(data.values[2]) ; 532 | HWLOGGING.print(data.values[3]) ; 533 | HWLOGGING.print(data.values[4]) ; 534 | HWLOGGING.println(data.idx) ; 535 | Display.file_Close(handle) ; 536 | Display.file_Erase(testdat) ; 537 | 538 | Display.file_FindFirstRet("*.dat", wks) ; 539 | HWLOGGING.println(wks) ; 540 | Display.file_FindNextRet(wks) ; 541 | HWLOGGING.print(wks) ; 542 | 543 | handle = Display.file_Open(testdat, 'w') ; 544 | HWLOGGING.print(F("Handle= ")) ; 545 | HWLOGGING.println(handle) ; 546 | i = sizeof(Image) ; 547 | k = 0 ; 548 | while (i != 0) 549 | { 550 | j = min(512, i) ; 551 | memcpy_P(wks, (char *)&Image[k], 512) ; 552 | Display.file_Write(j, &wks[0], handle) ; 553 | i -= j ; 554 | k += j ; 555 | } 556 | Display.file_Close(handle) ; 557 | Display.gfx_Cls() ; 558 | handle = Display.file_Open(testdat, 'r') ; 559 | Display.file_Image(0, 0, handle) ; 560 | Display.file_Close(handle) ; 561 | Display.gfx_MoveTo(40, 10) ; 562 | Display.putstr("4D Logo") ; 563 | 564 | Display.file_Erase(testdat) ; 565 | handle = Display.file_Open(testdat, 'w') ; 566 | HWLOGGING.print(F("Handle= ")) ; 567 | HWLOGGING.println(handle) ; 568 | Display.file_ScreenCapture(0, 0, 100, 32, handle) ; 569 | Display.file_Close(handle) ; 570 | 571 | handle = Display.file_Open(testdat, 'r') ; 572 | Display.file_Image(0, 40, handle) ; 573 | Display.file_Rewind(handle) ; 574 | Display.file_Image(0, 80, handle) ; 575 | Display.file_Rewind(handle) ; 576 | Display.file_Image(0, 120, handle) ; 577 | Display.file_Close(handle) ; 578 | Display.file_Erase(testdat) ; 579 | } 580 | 581 | void IMG_Tests(void) 582 | { 583 | word handle ; 584 | int i ; 585 | int j ; 586 | int k ; 587 | char wk[10] ; 588 | Display.gfx_Cls() ; 589 | Display.txt_MoveCursor(0, 5) ; 590 | Display.putstr("IMG Tests") ; 591 | HWLOGGING.println(F("IMG Tests")) ; 592 | handle = Display.file_LoadImageControl("gfx2demo.dat", "gfx2demo.gci", 1) ; 593 | HWLOGGING.print(handle) ; 594 | for (i = 0; i <= 4; i++) // 4 is "default", same as no dark/light ening 595 | { 596 | Display.gfx_BevelShadow(i) ; 597 | Display.img_Darken(handle, 0) ; 598 | Display.img_Show(handle, 0) ; 599 | delay(250) ; 600 | } 601 | for (i = 3; i >= 0; i--) 602 | { 603 | Display.gfx_BevelShadow(i) ; 604 | Display.img_Lighten(handle, 0) ; 605 | Display.img_Show(handle, 0) ; 606 | delay(250) ; 607 | } 608 | Display.gfx_BevelShadow(3) ; // back to default 609 | 610 | Display.img_SetPosition(handle, 0, 0, 50) ; // move to a different position 611 | Display.img_Show(handle, 0) ; 612 | 613 | j = Display.img_GetWord(handle, 0, IMAGE_FRAMES) ; 614 | for (i = 0; i < j; i++) 615 | { 616 | Display.img_SetWord(handle, 0, IMAGE_INDEX, i) ; 617 | Display.img_Show(handle, 0) ; 618 | delay(500) ; 619 | } 620 | 621 | delay(500) ; 622 | Display.img_Disable(handle, ALL) ; 623 | j = 0 ; 624 | k = 30 ; 625 | for (i = 36; i <= 39; i++) 626 | { 627 | Display.img_SetPosition(handle, i, j, k) ; // move to a different position 628 | if (j == 119) 629 | { 630 | k = 179 ; 631 | j = 0 ; 632 | } 633 | else 634 | j = 119 ; 635 | Display.img_Enable(handle, i) ; 636 | } 637 | Display.gfx_Cls() ; 638 | Display.img_Show(handle, ALL) ; 639 | // img_ClearAttributes(handle, index, value) ; 640 | // img_SetAttributes(handle, index, value) ; 641 | if (ftouchtests) 642 | { 643 | Display.touch_Set(TOUCH_ENABLE) ; 644 | Display.putstr("Please Touch an Image\n") ; 645 | i = -1 ; 646 | do 647 | { 648 | j = Display.touch_Get(TOUCH_STATUS) ; 649 | if (j == TOUCH_PRESSED) 650 | i = Display.img_Touched(handle, ALL) ; 651 | } while (i == -1) ; 652 | Display.putstr("You touched Image Index ") ; 653 | itoa(i, wk, 10) ; 654 | Display.putstr(wk) ; 655 | } 656 | Display.mem_Free(handle) ; 657 | } 658 | 659 | void Media_Tests(void) 660 | { 661 | long i ; 662 | int j ; 663 | unsigned long k ; 664 | int l ; 665 | int m , handle ; 666 | unsigned char sector[512] ; 667 | Display.gfx_Cls() ; 668 | Display.putstr("Media Tests") ; 669 | HWLOGGING.println(F("Media Tests")) ; 670 | Display.file_Unmount() ; // just to test this and media_Init 671 | i = Display.media_Init() ; 672 | if (i == 0) 673 | { 674 | HWLOGGING.print(F("Please insert the uSD card")) ; 675 | while (i == 0) 676 | { 677 | HWLOGGING.print(F(".")) ; 678 | i = Display.media_Init() ; 679 | } 680 | } 681 | 682 | HWLOGGING.print(F("\nFirst RAW sector=")) ; 683 | HWLOGGING.println(rawbase) ; 684 | trymount() ; 685 | 686 | handle = Display.file_Open("gfx2demo.gci", 'r') ; 687 | Display.file_Seek(handle, 0x49, 0x5800) ; // location of large unicorn file 688 | i = (long)128 * 128 * 13 * 2 + 8 ; // size of large unicorn file 689 | l = (i / 512) + 1 ; 690 | // we assume here that the raw partition is big enough to write this, could 691 | k = rawbase ; 692 | m = 1 ; 693 | while (i != 0) 694 | { 695 | HWLOGGING.print(F("Copying sector ")) ; 696 | HWLOGGING.print(m) ; 697 | HWLOGGING.print(F(" of ")) ; 698 | HWLOGGING.print(l) ; 699 | HWLOGGING.print(F("\r" )) ; // Arduino terminal monitor does not seem to recognise \r as of 1.02 700 | j = min(512, i) ; 701 | Display.file_Read((char *)sector, j, handle) ; 702 | Display.media_SetSector(k >> 16, k & 0xFFFF) ; 703 | k++ ; 704 | Display.media_WrSector((char *)sector) ; 705 | i -= j ; 706 | m++ ; 707 | } 708 | Display.file_Close(handle) ; 709 | Display.media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ; 710 | Display.media_Image(0, 0) ; 711 | Display.media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ; 712 | Display.media_Video(0, 128) ; 713 | 714 | Display.media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ; 715 | Display.media_WriteByte(0x11) ; 716 | Display.media_WriteWord(0x2233) ; 717 | Display.media_Flush() ; // should write 0xFF over the rest of the sector 718 | Display.media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ; 719 | HWLOGGING.print(Display.media_ReadByte(), HEX) ; 720 | HWLOGGING.print(F(" ")) ; 721 | HWLOGGING.print(Display.media_ReadWord(), HEX) ; 722 | HWLOGGING.print(F(" ")) ; 723 | HWLOGGING.println(Display.media_ReadWord(), HEX); 724 | } 725 | 726 | void Sound_Tests(void) 727 | { 728 | int i ; 729 | int j ; 730 | Display.gfx_Cls() ; 731 | HWLOGGING.println(F("Sound Tests")) ; 732 | Display.putstr("Sound Tests") ; 733 | Display.snd_Volume(127) ; 734 | Display.snd_BufSize(2) ; 735 | HWLOGGING.println(F("Playing")) ; 736 | Display.file_PlayWAV(soundtest) ; 737 | delay(10000) ; 738 | HWLOGGING.println(F("Pausing")) ; 739 | Display.snd_Pause() ; 740 | delay(5000) ; 741 | HWLOGGING.println(F("Continuing")) ; 742 | Display.snd_Continue() ; 743 | delay(5000) ; 744 | HWLOGGING.println(F("Playing with pitch")) ; 745 | i = Display.snd_Pitch(0xFFFF) ; 746 | HWLOGGING.print(F("Original Pitch=")) ; 747 | HWLOGGING.println(i) ; 748 | delay(5000) ; 749 | Display.snd_Pitch(trunc(i * 2 /*one octave, 1.0594631 one semitone*/)) ; 750 | delay(5000) ; 751 | Display.snd_Pitch(trunc(i / 2)) ; 752 | delay(5000) ; 753 | Display.snd_Pitch(i) ; 754 | delay(5000) ; 755 | for (j = 1; j <= 5; j++) 756 | { 757 | i = Display.snd_Playing() ; 758 | HWLOGGING.print(F("Blocks remaining= ")) ; 759 | HWLOGGING.print(i) ; 760 | HWLOGGING.print(F("\r")) ; // Arduino terminal monitor does not seem to recognise \r as of 1.02 761 | delay(2000) ; 762 | } 763 | HWLOGGING.println(F("")) ; 764 | for (i = 127; i >= 8; i--) 765 | { 766 | Display.snd_Volume(i) ; // 8 to 127 ; 767 | HWLOGGING.print(F("Volume=")) ; 768 | HWLOGGING.print(i) ; 769 | HWLOGGING.print(F("\r")) ; // Arduino terminal monitor does not seem to recognise \r as of 1.02 770 | delay(100) ; 771 | } 772 | HWLOGGING.println(F("\nStopping")) ; 773 | Display.snd_Stop() ; 774 | } 775 | 776 | void Touch_Tests(void) 777 | { 778 | int firstx ; 779 | int firsty ; 780 | int x ; 781 | int y ; 782 | int state ; 783 | Display.gfx_Cls() ; 784 | Display.putstr("Touch Tests\n") ; 785 | HWLOGGING.println(F("Touch Tests.")) ; 786 | Display.putstr("Please ensure Touch is only\ndetected in the Blue area") ; 787 | HWLOGGING.println(F("Detecting touch in Region")) ; 788 | Display.touch_Set(TOUCH_ENABLE) ; 789 | Display.touch_DetectRegion(100, 100, 200, 200) ; 790 | Display.gfx_RectangleFilled(100, 100, 200, 200, BLUE) ; 791 | do {} while (Display.touch_Get(TOUCH_STATUS) != TOUCH_PRESSED); 792 | Display.touch_Set(TOUCH_REGIONDEFAULT) ; 793 | Display.gfx_Cls() ; 794 | Display.putstr("Draw.. Drawing stops\nwhen touch released\n") ; 795 | HWLOGGING.println(F("Drawing")) ; 796 | 797 | while (Display.touch_Get(TOUCH_STATUS) != TOUCH_PRESSED) 798 | { // we"ll wait for a touch 799 | } 800 | firstx = Display.touch_Get(TOUCH_GETX); // so we can get the first point 801 | firsty = Display.touch_Get(TOUCH_GETY); 802 | while (state != TOUCH_RELEASED) 803 | { 804 | state = Display.touch_Get(TOUCH_STATUS); // look for any touch activity 805 | x = Display.touch_Get(TOUCH_GETX); // grab the x 806 | y = Display.touch_Get(TOUCH_GETY); // and the y coordinates of the touch 807 | if (state == TOUCH_PRESSED) // if there"s a press 808 | { 809 | firstx = x; 810 | firsty = y; 811 | } 812 | if (state == TOUCH_MOVING) // if there"s movement 813 | { 814 | Display.gfx_Line(firstx, firsty, x, y, BLUE); // but lines are much better 815 | firstx = x; 816 | firsty = y; 817 | } 818 | } 819 | Display.putstr("Done!\n") ; 820 | Display.touch_Set(TOUCH_DISABLE) ; 821 | } 822 | 823 | int freeRam () { 824 | extern int __heap_start, *__brkval; 825 | int v; 826 | return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 827 | } 828 | 829 | void mycallback(int ErrCode, unsigned char Errorbyte) 830 | { 831 | #ifdef LOG_MESSAGES 832 | const char *Error4DText[] = {"OK\0", "Timeout\0", "NAK\0", "Length\0", "Invalid\0"} ; 833 | HWLOGGING.print(F("Serial 4D Library reports error ")) ; 834 | HWLOGGING.print(Error4DText[ErrCode]) ; 835 | if (ErrCode == Err4D_NAK) 836 | { 837 | HWLOGGING.print(F(" returned data= ")) ; 838 | HWLOGGING.println(Errorbyte) ; 839 | } 840 | else 841 | HWLOGGING.println(F("")) ; 842 | while (1) ; // you can return here, or you can loop 843 | #else 844 | // Pin 13 has an LED connected on most Arduino boards. Just give it a name 845 | #define led 13 846 | while (1) 847 | { 848 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 849 | delay(200); // wait for a second 850 | digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 851 | delay(200); // wait for a second 852 | } 853 | #endif 854 | } 855 | 856 | #define RESETLINE 4 857 | 858 | void setup() 859 | { 860 | pinMode(13, OUTPUT); 861 | pinMode(RESETLINE, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset) 862 | digitalWrite(RESETLINE, 1); // Reset the Display via D4 863 | delay(100); 864 | digitalWrite(RESETLINE, 0); // unReset the Display via D4 865 | delay(5000); 866 | 867 | #ifdef LOG_MESSAGES 868 | HWLOGGING.begin(19200); 869 | HWLOGGING.print(F("\n\nBigDemo for Arduino\n")); 870 | #endif 871 | } 872 | 873 | void loop() 874 | { 875 | int i, rc ; 876 | char wks[20] ; 877 | DisplaySerial.begin(9600) ; 878 | Display.TimeLimit4D = 5000 ; // 5 second timeout on all commands 879 | // Display.Callback4D = NULL ; 880 | Display.Callback4D = mycallback ; 881 | 882 | Display.gfx_Cls() ; 883 | fFATtests = trymount() ; 884 | fmediatests = false ; 885 | fimgtests = false ; 886 | ftouchtests = false ; 887 | floadtests = false ; 888 | fsoundtests = false ; 889 | // Display.gfx_Cls() ; 890 | Display.sys_GetModel(wks) ; // length is also returned, but we don't need that here 891 | HWLOGGING.print(F("Display model: ")) ; 892 | HWLOGGING.println(wks) ; 893 | Display.putstr("Display model: ") ; 894 | Display.putstr(wks) ; 895 | i = strlen(wks) ; 896 | if ( (wks[i] == 'T') 897 | || (wks[i - 1] == 'T') 898 | || (wks[i - 2] == 'T') ) 899 | ftouchtests = true ; 900 | //for(int j=0; j<= i; j++) 901 | //{ 902 | // HWLOGGING.write(wks[j]); 903 | //} 904 | ftouchtests = true; 905 | HWLOGGING.print(F("SPE2 Version: ")) ; 906 | HWLOGGING.println(Display.sys_GetVersion(), HEX) ; 907 | HWLOGGING.print(F("PmmC Version: ")) ; 908 | HWLOGGING.println(Display.sys_GetPmmC(), HEX) ; 909 | if (fFATtests) 910 | { 911 | if (RAWPartitionbase(&rawbase)) 912 | fmediatests = true ; 913 | if ( (Display.file_Exists(gfx2demodat) != 0) 914 | && (Display.file_Exists(gfx2demogci) != 0) ) 915 | fimgtests = true ; 916 | if ( (Display.file_Exists(functest) != 0) 917 | && (Display.file_Exists(functestg) != 0) 918 | && (Display.file_Exists(functestd) != 0) ) 919 | floadtests = true ; 920 | if (Display.file_Exists(soundtest)) 921 | fsoundtests = true ; 922 | } 923 | if (fFATtests) 924 | { 925 | HWLOGGING.println(F("FAT Tests will be done")) ; 926 | if (fmediatests) 927 | { 928 | if (Display.file_Exists(gfx2demogci)) 929 | HWLOGGING.println(F("Media tests will be done\n")) ; 930 | else 931 | { 932 | HWLOGGING.print(F("Media tests cannot be done, missing ")) ; 933 | HWLOGGING.println(gfx2demogci) ; 934 | fmediatests = false ; 935 | } 936 | } 937 | else 938 | HWLOGGING.println(F("Media tests cannot be done, no RAW Partition")) ; 939 | if (fimgtests) 940 | HWLOGGING.println(F("Image tests will be done")) ; 941 | else 942 | { 943 | HWLOGGING.print(F("Image tests will not be done, missing ")) ; 944 | HWLOGGING.print(gfx2demogci) ; 945 | HWLOGGING.print(F(" or ")) ; 946 | HWLOGGING.println(gfx2demodat) ; 947 | } 948 | if (floadtests) 949 | HWLOGGING.println(F("Load tests will be done")) ; 950 | else 951 | { 952 | HWLOGGING.print(F("Load tests will not be done, missing ")) ; 953 | HWLOGGING.print(functest) ; 954 | HWLOGGING.print(F(" or ")) ; 955 | HWLOGGING.print(functestg) ; 956 | HWLOGGING.print(F(" or ")) ; 957 | HWLOGGING.println(functestd) ; 958 | } 959 | if (fsoundtests) 960 | HWLOGGING.println(F("Sound tests will be done")) ; 961 | else 962 | { 963 | HWLOGGING.print(F("Sound tests will not be done, missing ")) ; 964 | HWLOGGING.println(soundtest) ; 965 | } 966 | } 967 | else 968 | { 969 | HWLOGGING.println(F("FAT Tests cannot be done, either no uSD card or no FAT partition")) ; 970 | HWLOGGING.println(F("Neither will Media, Image, Load or Sound Tests")) ; 971 | } 972 | if (ftouchtests) 973 | HWLOGGING.println(F("Touch Tests will be done")) ; 974 | else 975 | HWLOGGING.println(F("Touch Tests will not be done, display doesn't appear capable")) ; 976 | 977 | // HWLOGGING.println(freeRam()) ; 978 | delay(5000) ; 979 | 980 | #ifdef TEST_OTHER 981 | gfx_Part1() ; // GFX Part 1 tests 982 | delay(5000) ; 983 | 984 | gfx_Part2() ; // GFX Part 2 tests 985 | delay(5000) ; 986 | 987 | text_Tests() ; // text tests 988 | delay(5000) ; 989 | #endif 990 | 991 | #ifdef TEST_USD 992 | if (fFATtests) 993 | { 994 | FAT_Tests() ; 995 | delay(5000) ; 996 | } 997 | if (fimgtests) 998 | { 999 | IMG_Tests() ; 1000 | delay(5000) ; 1001 | } 1002 | 1003 | if (fmediatests) 1004 | { 1005 | Media_Tests() ; 1006 | delay(5000) ; 1007 | } 1008 | 1009 | if (floadtests) 1010 | { 1011 | Function_Tests() ; 1012 | delay(5000) ; 1013 | } 1014 | 1015 | if (fsoundtests) 1016 | { 1017 | Sound_Tests() ; 1018 | delay(5000) ; 1019 | } 1020 | #endif 1021 | 1022 | #ifdef TEST_OTHER 1023 | if (ftouchtests) 1024 | { 1025 | Touch_Tests() ; 1026 | delay(5000) ; 1027 | } 1028 | 1029 | Display.setbaudWait(BAUD_19200) ; 1030 | Display.putstr("Hello at 19200\n") ; 1031 | Display.setbaudWait(BAUD_9600) ; 1032 | Display.putstr("Back to 9600\n") ; 1033 | delay(5000) ; 1034 | #endif 1035 | } 1036 | --------------------------------------------------------------------------------