PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Examples/colour_main/colour_main.pde

https://github.com/Ctemes/Serial_LCD
Processing | 197 lines | 101 code | 52 blank | 44 comment | 10 complexity | 5234f6df05c7a950030b45d003254511 MD5 | raw file
  1///
  2/// @file 	colour_main.pde
  3/// @brief	Example
  4/// @details 	
  5/// @n @a 	Example for Serial_LCD Library Suite
  6/// @n @a	for 4D Systems uLCD-uLED-uVGA Serial_LCD Library Suite
  7/// @n 		on Arduino 0023 and 1.0, chipKIT MPIDE 0023, Wiring 1.0
  8///
  9/// @a 		Developed with [embedXcode](http://embedXcode.weebly.com)
 10/// 
 11/// @author 	Rei VILO
 12/// @author 	http://embeddedcomputing.weebly.com
 13/// @date	Jul 12, 2012
 14/// @version	release 132
 15/// @n
 16/// @copyright 	Š Rei VILO, 2010-2012
 17/// @copyright 	CC = BY NC SA
 18/// @n		http://embeddedcomputing.weebly.com/serial-lcd.html
 19/// @n		http://github.com/rei-vilo/Serial_LCD
 20///
 21/// @see 	4D Systems Goldelox and Picaso SGC Command Set
 22/// @n		http://www.4dsystems.com.au/
 23///
 24
 25// Core library - MCU-based
 26#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) // Arduino specific
 27  #if defined(ARDUINO) && (ARDUINO >= 100)
 28  #include "Arduino.h" // for Arduino 1.0
 29  #else
 30  #include "WProgram.h" // for Arduino 23
 31  #endif
 32#elif defined(__32MX320F128H__) || defined(__32MX795F512L__) // chipKIT specific 
 33#include "WProgram.h"
 34#elif defined(__AVR_ATmega644P__) // Wiring specific
 35#include "Wiring.h"
 36#else // error
 37#error Platform not supported
 38#endif
 39
 40#include "Serial_LCD.h"
 41#include "proxySerial.h"
 42
 43// test release
 44#if SERIAL_LCD_RELEASE < 333
 45#error required SERIAL_LCD_RELEASE 333
 46#endif
 47
 48// uncomment for I2C serial interface
 49//#define __I2C_Serial__
 50
 51// === Serial port choice ===
 52#if defined(__I2C_Serial__) // I2C serial
 53  #include "Wire.h"
 54  #include "I2C_Serial.h"
 55  I2C_Serial mySerial(0);
 56
 57#elif defined(__AVR_ATmega328P__) // software serial
 58  #if defined(ARDUINO) && (ARDUINO>=100) // for Arduino 1.0
 59    #include "SoftwareSerial.h"
 60    SoftwareSerial mySerial(2, 3);
 61  #else
 62    #include "NewSoftSerial.h" // for Arduino 23
 63    NewSoftSerial mySerial(2, 3);
 64  #endif
 65
 66#elif defined(__32MX320F128H__) || defined(__32MX795F512L__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega644P__) // hardware serial Serial1
 67  #define mySerial Serial1
 68
 69#else // error
 70  #error Platform not defined
 71#endif
 72// === End of Serial port choice ===
 73
 74ProxySerial myPort(&mySerial); // hardware abstraction layer
 75Serial_LCD myLCD(&myPort); // LCD
 76
 77
 78void setup() {
 79  Serial.begin(19200);
 80  Serial.print("\n\n\n***\n");
 81
 82  // === Serial port initialisation ===
 83#if defined(__I2C_Serial__)
 84  Serial.print("i2c\n");
 85  Wire.begin();
 86  mySerial.begin(9600);
 87
 88#elif defined(__AVR__)  || defined(__AVR_ATmega328P__) | defined(__AVR_ATmega328P__)
 89  Serial.print("avr\n");
 90  mySerial.begin(9600);
 91
 92#elif defined(__PIC32MX__) 
 93  Serial.print("chipKIT\n");
 94  Serial1.begin(9600);
 95
 96#endif 
 97  // === End of Serial port initialisation ===
 98
 99  myLCD.begin();
100
101  //  // === Serial port speed change ===
102  //  myLCD.setSpeed(38400);
103  //#if defined(__I2C_Serial__)
104  //  mySerial.begin(38400);
105  //
106  //#elif defined(__AVR__)  || defined(__AVR_ATmega328P__) | defined(__AVR_ATmega328P__)
107  //  mySerial.begin(38400);
108  //
109  //#elif defined(__PIC32MX__) 
110  //  Serial1.begin(38400);
111  //
112  //#endif 
113  //  // === End of Serial port speed change ===
114
115
116
117  int8_t i;
118
119
120  myLCD.setPenSolid(true);
121
122  i=0;  
123  myLCD.dRectangle(20*i, 0, 17, 100, blackColour);
124  i++;  
125  myLCD.dRectangle(20*i, 0, 17, 100, whiteColour);
126  i++;  
127  myLCD.dRectangle(20*i, 0, 17, 100, redColour);
128  i++;  
129  myLCD.dRectangle(20*i, 0, 17, 100, greenColour);
130  i++;  
131  myLCD.dRectangle(20*i, 0, 17, 100, blueColour);
132  i++;  
133  myLCD.dRectangle(20*i, 0, 17, 100, yellowColour);
134  i++;  
135  myLCD.dRectangle(20*i, 0, 17, 100, cyanColour);
136  i++;  
137  myLCD.dRectangle(20*i, 0, 17, 100, orangeColour);
138  i++;  
139  myLCD.dRectangle(20*i, 0, 17, 100, magentaColour);
140  i++;
141  myLCD.dRectangle(20*i, 0, 17, 100, violetColour);
142  i++;
143  myLCD.dRectangle(20*i, 0, 17, 100, grayColour);
144
145
146  i=0;  
147  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(blackColour));
148  i++;  
149  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(whiteColour));
150  i++;  
151  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(redColour));
152  i++;  
153  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(greenColour));
154  i++;  
155  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(blueColour));
156  i++;  
157  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(yellowColour));
158  i++;  
159  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(cyanColour));
160  i++;  
161  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(orangeColour));
162  i++;  
163  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(magentaColour));
164  i++;
165  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(violetColour));
166  i++;
167  myLCD.dRectangle(20*i, 100, 17, 100, myLCD.reverseColour(grayColour));
168
169
170}
171
172
173void loop() {
174}
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197