annotate service/busyboxArduino/main.ino @ 158:75b1dc5c0bdc

notes on pins Ignore-this: 1fced0c832715c5fbd16011563e7120a
author drewp@bigasterisk.com
date Mon, 19 Jan 2015 21:38:11 -0800
parents 28c2db876548
children 4c62b6d416a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
158
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
1 /*
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
2 D0 <---------
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
3 D1 lcd rw
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
4 D2 <---------
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
5 D3 ir out -----
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
6 D4 lcd 4
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
7 D5 lcd 5
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
8 D6 lcd 6
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
9 D7 lcd 7
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
10 D8 lcd rs
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
11 D9 lcd en
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
12 D10 lcd backlight
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
13 D11 tbd <------------
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
14 D12 motion in <--------
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
15 D13 debug led <--------
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
16
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
17 */
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
18 #include <Arduino.h>
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
19 #include <LiquidCrystal.h>
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
20 #include "DFR_Key.h"
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
21 #include "IRremote.h"
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
22
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
23 // see http://www.dfrobot.com/image/data/DFR0009/LCDKeypad%20Shield%20V1.0%20SCH.pdf
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
24 #define I2C_ADDR 0x27 // I2C address of PCF8574A
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
25 #define BACKLIGHT_PIN 10
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
26 #define En_pin 9
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
27 #define Rw_pin 1
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
28 #define Rs_pin 8
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
29 #define D4_pin 4
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
30 #define D5_pin 5
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
31 #define D6_pin 6
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
32 #define D7_pin 7
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
33
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
34 LiquidCrystal lcd(Rs_pin, Rw_pin, En_pin, D4_pin, D5_pin, D6_pin, D7_pin, BACKLIGHT_PIN, POSITIVE);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
35 DFR_Key keypad;
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
36
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
37 #define debugLed 13
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
38
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
39 byte backlightStandard = 0;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
40 byte backlightCurrent = 0;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
41 byte backlightKeypressBoost = 30;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
42
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
43 int lastKey = -1;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
44 int lastUnsentKeydown = -1;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
45 uint16_t steps = 0;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
46 uint16_t stepDelayPerBrightnessFade = 2048;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
47
158
75b1dc5c0bdc notes on pins
drewp@bigasterisk.com
parents: 157
diff changeset
48 // uses pin 3
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
49 IRsend irsend;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
50
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
51 void sendnec(byte addr, byte cmd) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
52 uint32_t w = 0x00ff0000;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
53 w |= (cmd << 8) & 0xff00;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
54 w |= (~cmd) & 0xff;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
55 irsend.sendNEC(w, 32);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
56 delay(100);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
57 }
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
58
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
59 void setup(void) {
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
60 pinMode(debugLed, OUTPUT);
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
61 Serial.begin(115200);
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
62 keypad.setRate(10);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
63 lcd.begin(16,2);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
64
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
65
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
66 for (int i = 0; i < 1; i++) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
67 digitalWrite(debugLed,1);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
68 /*
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
69 44 key remote. command chart: http://blog.allgaiershops.com/2012/05/
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
70 Up Down Play Pwr
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
71 0x3A 0xBA 0x82 0x02
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
72
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
73 Red Grn Blu Wht
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
74 1A 9A A2 22
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
75
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
76 2A AA 92 12
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
77
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
78 0A 8A B2 32
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
79
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
80 38 B8 78 F8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
81
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
82 18 98 58 D8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
83
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
84 RUp GUp BUp Quick
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
85 28 A8 68 E8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
86
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
87 RDn GDn BDn Slow
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
88 08 88 48 C8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
89
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
90 DIY1 DIY2 DIY3 AUTO
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
91 30 B0 70 F0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
92
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
93 DIY4 DIY5 DIY6 Flash
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
94 10 90 50 D0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
95
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
96 JMP3 JMP7 Fade Fade7
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
97 20 A0 60 E0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
98
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
99 irsend.sendNEC(0xff0002fd, 32);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
100 irsend.sendNEC(0x00ff02fd, 32);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
101 irsend.sendNEC(0x00ff40bf, 32);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
102 irsend.sendNEC(0xff0040bf, 32);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
103 */
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
104 delay(100);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
105
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
106 // LED618 remote command byte (addr is ff)
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
107 // see https://github.com/alistairallan/RgbIrLed/blob/master/RgbIrLed.cpp#L44
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
108 #define ON 0xE0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
109 #define OFF 0x60
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
110 #define BRIGHTNESS_UP 0xA0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
111 #define BRIGHTNESS_DOWN 0x20
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
112 #define FLASH 0xF0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
113 #define STROBE 0xE8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
114 #define FADE 0xD8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
115 #define SMOOTH 0xC8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
116
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
117 #define RED 0x90
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
118 #define GREEN 0x10
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
119 #define BLUE 0x50
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
120 #define WHITE 0xD0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
121
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
122 #define ORANGE 0xB0
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
123 #define YELLOW_DARK 0xA8
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
124 #define YELLOW_MEDIUM 0x98
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
125 #define YELLOW_LIGHT 0x88
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
126
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
127 #define GREEN_LIGHT 0x30
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
128 #define GREEN_BLUE1 0x28
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
129 #define GREEN_BLUE2 0x18
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
130 #define GREEN_BLUE3 0x08
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
131
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
132 #define BLUE_RED 0x70
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
133 #define PURPLE_DARK 0x68
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
134 #define PURPLE_LIGHT 0x58
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
135 #define PINK 0x48
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
136 sendnec(0xff, ON);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
137
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
138 digitalWrite(debugLed,0);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
139 delay(100);
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
140 }
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
141 }
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
142
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
143
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
144 void loop() {
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
145 while (Serial.available() <= 2) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
146 int localKey = keypad.getKey();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
147 if (localKey != SAMPLE_WAIT) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
148 if (localKey != lastKey) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
149 if (lastKey == 0) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
150 backlightCurrent = min(255, backlightStandard +
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
151 backlightKeypressBoost);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
152 lastUnsentKeydown = localKey;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
153 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
154 lastKey = localKey;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
155 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
156 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
157
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
158 if (backlightCurrent > backlightStandard) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
159 steps++;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
160 if (steps % stepDelayPerBrightnessFade == 0) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
161 backlightCurrent--;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
162 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
163 } else if (backlightCurrent < backlightStandard) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
164 backlightCurrent = backlightStandard;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
165 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
166 lcd.setBacklight(backlightCurrent);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
167 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
168 byte i = Serial.read();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
169 if (i != 0x60) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
170 return;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
171 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
172 i = Serial.read(); // command
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
173 if (i == 0) { // get status
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
174 Serial.print('{');
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
175 if (lastUnsentKeydown != -1) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
176 Serial.print("\"keyDown\":");
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
177 Serial.print(lastUnsentKeydown);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
178 Serial.print(",");
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
179 lastUnsentKeydown = -1;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
180 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
181 Serial.print("\"slider1\":"); Serial.print(analogRead(1));
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
182 Serial.print(",\"slider2\":"); Serial.print(analogRead(2));
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
183 Serial.print(",\"slider3\":"); Serial.print(analogRead(3));
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
184 Serial.print(",\"slider4\":"); Serial.print(analogRead(4));
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
185 Serial.print("}\n");
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
186 } else if (i == 1) { // write text
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
187 while (Serial.available() < 3) NULL;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
188 byte row = Serial.read();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
189 byte col = Serial.read();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
190 byte nchars = Serial.read();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
191 char buf[32];
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
192 char *p=buf;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
193 while (nchars--) {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
194 while (Serial.available() < 1) NULL;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
195 *(p++) = Serial.read();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
196 }
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
197 *p = 0;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
198 lcd.setCursor(row, col);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
199 lcd.print(buf);
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
200 } else if (i == 2) { // set backlight
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
201 while (Serial.available() < 1) NULL;
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
202 backlightStandard = Serial.read();
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
203 } else {
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
204 // unknown command
28c2db876548 busybox py and arduino
drewp@bigasterisk.com
parents: 153
diff changeset
205 }
153
f8c5ec994768 start buttons+lcd program
drewp@bigasterisk.com
parents:
diff changeset
206 }