@@ -88,7 +88,7 @@ uint8_t readCapacitivePin(String data) {
8888 else if (*pin & bitmask) { cycles = 16 ;}
8989
9090 // Discharge the pin again by setting it low and output
91- // It's important to leave the pins low if you want to
91+ // It's important to leave the pins low if you want to
9292 // be able to touch more than 1 sensor at a time - if
9393 // the sensor is left pulled high, when you touch
9494 // two sensors, your body will transfer the charge between
@@ -118,12 +118,12 @@ void Tone(String data){
118118 delay (pause);
119119 noTone (pin);
120120 }
121- }
121+ }
122122
123123void ToneNo (String data){
124124 int pin = Str2int (data);
125125 noTone (pin);
126- }
126+ }
127127
128128void DigitalHandler (int mode, String data){
129129 int pin = Str2int (data);
@@ -161,7 +161,7 @@ void ConfigurePinHandler(String data){
161161 }
162162}
163163
164- void shiftOutHandler (String data) {
164+ void shiftOutHandler (String data) {
165165 String sdata[4 ];
166166 split (sdata, 4 , data, ' %' );
167167 int dataPin = sdata[0 ].toInt ();
@@ -207,10 +207,10 @@ void SS_write(String data) {
207207 char buffer[len];
208208 data.toCharArray (buffer,len);
209209 Serial.println (" ss OK" );
210- sserial->write (buffer);
210+ sserial->write (buffer);
211211}
212212void SS_read (String data) {
213- char c = sserial->read ();
213+ char c = sserial->read ();
214214 Serial.println (c);
215215}
216216
@@ -219,10 +219,10 @@ void pulseInHandler(String data){
219219 long duration;
220220 if (pin <=0 ){
221221 pinMode (-pin, INPUT );
222- duration = pulseIn (-pin, LOW );
222+ duration = pulseIn (-pin, LOW );
223223 }else {
224224 pinMode (pin, INPUT );
225- duration = pulseIn (pin, HIGH );
225+ duration = pulseIn (pin, HIGH );
226226 }
227227 Serial.println (duration);
228228}
@@ -238,7 +238,7 @@ void pulseInSHandler(String data){
238238 delayMicroseconds (5 );
239239 digitalWrite (-pin, HIGH );
240240 pinMode (-pin, INPUT );
241- duration = pulseIn (-pin, LOW );
241+ duration = pulseIn (-pin, LOW );
242242 }else {
243243 pinMode (pin, OUTPUT );
244244 digitalWrite (pin, LOW );
@@ -247,7 +247,7 @@ void pulseInSHandler(String data){
247247 delayMicroseconds (5 );
248248 digitalWrite (pin, LOW );
249249 pinMode (pin, INPUT );
250- duration = pulseIn (pin, HIGH );
250+ duration = pulseIn (pin, HIGH );
251251 }
252252 Serial.println (duration);
253253}
@@ -315,8 +315,8 @@ void sizeEEPROM() {
315315void EEPROMHandler (int mode, String data) {
316316 String sdata[2 ];
317317 split (sdata, 2 , data, ' %' );
318- if (mode == 0 ) {
319- EEPROM .write (Str2int (sdata[0 ]), Str2int (sdata[1 ]));
318+ if (mode == 0 ) {
319+ EEPROM .write (Str2int (sdata[0 ]), Str2int (sdata[1 ]));
320320 } else {
321321 Serial.println (EEPROM .read (Str2int (sdata[0 ])));
322322 }
@@ -326,12 +326,12 @@ int dhtSensorPin = -1;
326326DHT dhtSensor (dhtSensorPin, DHT11 );
327327
328328void dht (String data) {
329-
329+
330330 String sdata[2 ];
331331 split (sdata, 2 , data, ' %' );
332332 int dataPin = sdata[0 ].toInt ();
333333 int sensorNumber = sdata[1 ].toInt ();
334-
334+
335335 int sensorType = DHT11 ; // assume DHT11 as default
336336 if (sensorNumber == 1 ) {
337337 sensorType = DHT12 ;
@@ -355,12 +355,12 @@ void dht(String data) {
355355 float h = dhtSensor.readHumidity ();
356356 // Read temperature as Celsius (the default)
357357 float t = dhtSensor.readTemperature ();
358-
358+
359359 if (isnan (h) || isnan (t)) {
360360 Serial.println (" 0&0&0" );
361361 return ;
362362 }
363-
363+
364364 float hic = dhtSensor.computeHeatIndex (t, h, false );
365365 Serial.println (String (h) + " &" + String (t) + " &" + String (hic));
366366}
@@ -371,26 +371,26 @@ void dht(String data) {
371371// A large function to set up the display, clear it from previously, set a line(s) of text, and write it.
372372// TODO: I was unable to break this apart into different functions to play around with in Python, due to issues with variable scope. I will come back to this.
373373void displayText (String data) {
374-
374+
375375 int screen_height = 32 ;
376376 int screen_width = 128 ;
377-
377+
378378 // The analog pin number connected to the reset pin of the screen (SDA).
379379 int reset_pin = 4 ;
380380
381381 // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins).
382- Adafruit_SSD1306 display (screen_width, screen_height, &Wire, 4 );
382+ Adafruit_SSD1306 display (screen_width, screen_height, &Wire, 4 );
383383
384384 display.begin (SSD1306_SWITCHCAPVCC , 0x3C );
385-
385+
386386 // Clears previously displayed data and resets the cursor and text colour.
387387 display.clearDisplay ();
388388 display.setCursor (0 ,0 );
389389 display.setTextColor (WHITE );
390390
391- // The input data string contains the text to be written, along with %#,
392- // where # is the font size. This sets the font size by reading the last
393- // character of the input data (by default it is 1), and converting it
391+ // The input data string contains the text to be written, along with %#,
392+ // where # is the font size. This sets the font size by reading the last
393+ // character of the input data (by default it is 1), and converting it
394394 // to an int. Once that is done, the last two characters are deleted.
395395 int font_size = data[data.length () - 1 ] - 48 ;
396396 display.setTextSize (font_size);
@@ -414,64 +414,64 @@ void SerialParser(void) {
414414 // separate command from associated data
415415 String cmd = read_.substring (1 ,idx1);
416416 String data = read_.substring (idx1+1 ,idx2);
417-
417+
418418 // determine command sent
419419 if (cmd == " dw" ) {
420- DigitalHandler (1 , data);
420+ DigitalHandler (1 , data);
421421 }
422422 else if (cmd == " dr" ) {
423- DigitalHandler (0 , data);
424- }
423+ DigitalHandler (0 , data);
424+ }
425425 else if (cmd == " aw" ) {
426- AnalogHandler (1 , data);
427- }
426+ AnalogHandler (1 , data);
427+ }
428428 else if (cmd == " ar" ) {
429- AnalogHandler (0 , data);
430- }
429+ AnalogHandler (0 , data);
430+ }
431431 else if (cmd == " pm" ) {
432- ConfigurePinHandler (data);
433- }
432+ ConfigurePinHandler (data);
433+ }
434434 else if (cmd == " ps" ) {
435- pulseInSHandler (data);
436- }
435+ pulseInSHandler (data);
436+ }
437437 else if (cmd == " pi" ) {
438- pulseInHandler (data);
439- }
438+ pulseInHandler (data);
439+ }
440440 else if (cmd == " ss" ) {
441- SS_set (data);
441+ SS_set (data);
442442 }
443443 else if (cmd == " sw" ) {
444- SS_write (data);
444+ SS_write (data);
445445 }
446446 else if (cmd == " sr" ) {
447- SS_read (data);
448- }
447+ SS_read (data);
448+ }
449449 else if (cmd == " sva" ) {
450- SV_add (data);
451- }
450+ SV_add (data);
451+ }
452452 else if (cmd == " svr" ) {
453- SV_read (data);
454- }
453+ SV_read (data);
454+ }
455455 else if (cmd == " svw" ) {
456- SV_write (data);
457- }
456+ SV_write (data);
457+ }
458458 else if (cmd == " svwm" ) {
459- SV_write_ms (data);
460- }
459+ SV_write_ms (data);
460+ }
461461 else if (cmd == " svd" ) {
462- SV_remove (data);
463- }
462+ SV_remove (data);
463+ }
464464 else if (cmd == " version" ) {
465- Version ();
465+ Version ();
466466 }
467467 else if (cmd == " to" ) {
468- Tone (data);
469- }
468+ Tone (data);
469+ }
470470 else if (cmd == " nto" ) {
471- ToneNo (data);
472- }
471+ ToneNo (data);
472+ }
473473 else if (cmd == " cap" ) {
474- readCapacitivePin (data);
474+ readCapacitivePin (data);
475475 }
476476 else if (cmd == " so" ) {
477477 shiftOutHandler (data);
@@ -480,12 +480,12 @@ void SerialParser(void) {
480480 shiftInHandler (data);
481481 }
482482 else if (cmd == " eewr" ) {
483- EEPROMHandler (0 , data);
484- }
483+ EEPROMHandler (0 , data);
484+ }
485485 else if (cmd == " eer" ) {
486- EEPROMHandler (1 , data);
487- }
488- else if (cmd == " sz" ) {
486+ EEPROMHandler (1 , data);
487+ }
488+ else if (cmd == " sz" ) {
489489 sizeEEPROM ();
490490 }
491491 else if (cmd == " dht" ) {
@@ -498,7 +498,7 @@ void SerialParser(void) {
498498}
499499
500500void setup () {
501- Serial.begin (115200 );
501+ Serial.begin (115200 );
502502 while (!Serial) {
503503 ; // wait for serial port to connect. Needed for Leonardo only
504504 }
0 commit comments