From 91c34afc49d029e6b9a660392782be2fefda1443 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Wed, 31 Mar 2021 13:52:42 +0100 Subject: [PATCH] Replace deprecated boolean type Note that Processing sketches (pde type) do not accept bool, so boolean is correct. --- Extensions/Touch.h | 4 +++- examples/160 x 128/TFT_Clock/TFT_Clock.ino | 2 +- .../TFT_Clock_Digital/TFT_Clock_Digital.ino | 2 +- .../320 x 240/Keypad_240x320/Keypad_240x320.ino | 2 +- examples/320 x 240/TFT_Clock/TFT_Clock.ino | 2 +- examples/320 x 240/TFT_Terminal/TFT_Terminal.ino | 4 ++-- examples/480 x 320/Graph_2/Graph_2.ino | 8 ++++---- .../480 x 320/Keypad_480x320/Keypad_480x320.ino | 2 +- .../480 x 320/TFT_ring_meter/TFT_ring_meter.ino | 4 ++-- .../Generic/Animated_Eyes_1/eye_functions.ino | 2 +- .../Generic/Animated_Eyes_2/eye_functions.ino | 2 +- .../ESP32_SDcard_jpeg/ESP32_SDcard_jpeg.ino | 4 ++-- .../ESP8266_uncannyEyes/ESP8266_uncannyEyes.ino | 2 +- examples/Generic/On_Off_Button/On_Off_Button.ino | 2 +- .../TFT_Button_Label_Datum.ino | 2 +- .../TFT_Screen_Capture/processing_sketch.ino | 16 ++++++++-------- .../Generic/TFT_Screen_Capture/screenServer.ino | 12 ++++++------ .../Generic/Touch_calibrate/Touch_calibrate.ino | 2 +- 18 files changed, 38 insertions(+), 36 deletions(-) diff --git a/Extensions/Touch.h b/Extensions/Touch.h index 4cefab2..d691697 100644 --- a/Extensions/Touch.h +++ b/Extensions/Touch.h @@ -9,7 +9,9 @@ // Convert raw x,y values to calibrated and correctly rotated screen coordinates void convertRawXY(uint16_t *x, uint16_t *y); // Get the screen touch coordinates, returns true if screen has been touched - // if the touch cordinates are off screen then x and y are not updated + // if the touch coordinates are off screen then x and y are not updated + // The returned value can be treated as a bool type, false or 0 means touch not detected + // In future the function may return an 8 "quality" (jitter) value. uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600); // Run screen calibration and test, report calibration values to the serial port diff --git a/examples/160 x 128/TFT_Clock/TFT_Clock.ino b/examples/160 x 128/TFT_Clock/TFT_Clock.ino index 9248c68..b6e4e43 100644 --- a/examples/160 x 128/TFT_Clock/TFT_Clock.ino +++ b/examples/160 x 128/TFT_Clock/TFT_Clock.ino @@ -33,7 +33,7 @@ static uint8_t conv2d(const char* p) { uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time -boolean initial = 1; +bool initial = 1; void setup(void) { tft.init(); diff --git a/examples/160 x 128/TFT_Clock_Digital/TFT_Clock_Digital.ino b/examples/160 x 128/TFT_Clock_Digital/TFT_Clock_Digital.ino index 5966726..3fc35b8 100644 --- a/examples/160 x 128/TFT_Clock_Digital/TFT_Clock_Digital.ino +++ b/examples/160 x 128/TFT_Clock_Digital/TFT_Clock_Digital.ino @@ -36,7 +36,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h uint32_t targetTime = 0; // for next 1 second timeout byte omm = 99; -boolean initial = 1; +bool initial = 1; byte xcolon = 0; unsigned int colour = 0; diff --git a/examples/320 x 240/Keypad_240x320/Keypad_240x320.ino b/examples/320 x 240/Keypad_240x320/Keypad_240x320.ino index a6c503f..e38e6f4 100644 --- a/examples/320 x 240/Keypad_240x320/Keypad_240x320.ino +++ b/examples/320 x 240/Keypad_240x320/Keypad_240x320.ino @@ -108,7 +108,7 @@ void loop(void) { uint16_t t_x = 0, t_y = 0; // To store the touch coordinates // Pressed will be set true is there is a valid touch on the screen - boolean pressed = tft.getTouch(&t_x, &t_y); + bool pressed = tft.getTouch(&t_x, &t_y); // / Check if any key coordinate boxes contain the touch coordinates for (uint8_t b = 0; b < 15; b++) { diff --git a/examples/320 x 240/TFT_Clock/TFT_Clock.ino b/examples/320 x 240/TFT_Clock/TFT_Clock.ino index 9225ae2..0f77e1f 100644 --- a/examples/320 x 240/TFT_Clock/TFT_Clock.ino +++ b/examples/320 x 240/TFT_Clock/TFT_Clock.ino @@ -33,7 +33,7 @@ uint32_t targetTime = 0; // for next 1 second timeout static uint8_t conv2d(const char* p); // Forward declaration needed for IDE 1.6.x uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time -boolean initial = 1; +bool initial = 1; void setup(void) { tft.init(); diff --git a/examples/320 x 240/TFT_Terminal/TFT_Terminal.ino b/examples/320 x 240/TFT_Terminal/TFT_Terminal.ino index c204302..27fb4f1 100644 --- a/examples/320 x 240/TFT_Terminal/TFT_Terminal.ino +++ b/examples/320 x 240/TFT_Terminal/TFT_Terminal.ino @@ -48,8 +48,8 @@ uint16_t xPos = 0; byte data = 0; // A few test variables used during debugging -boolean change_colour = 1; -boolean selected = 1; +bool change_colour = 1; +bool selected = 1; // We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds // for a full width line, meanwhile the serial buffer may be filling... and overflowing diff --git a/examples/480 x 320/Graph_2/Graph_2.ino b/examples/480 x 320/Graph_2/Graph_2.ino index 5b16db3..d1bb0b8 100644 --- a/examples/480 x 320/Graph_2/Graph_2.ino +++ b/examples/480 x 320/Graph_2/Graph_2.ino @@ -60,8 +60,8 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with defau // and will mimize flicker // also create some variables to store the old x and y, if you draw 2 graphs on the same display // you will need to store ox and oy per each display -boolean display1 = true; -boolean update1 = true; +bool display1 = true; +bool update1 = true; double ox = -999, oy = -999; // Force them to be off screen @@ -97,7 +97,7 @@ void Graph(TFT_eSPI &tft, double x, double y, byte dp, double xlo, double xhi, double xinc, double ylo, double yhi, double yinc, char *title, char *xlabel, char *ylabel, - boolean &redraw, unsigned int color) { + bool &redraw, unsigned int color) { double ydiv, xdiv; double i; @@ -191,7 +191,7 @@ void Trace(TFT_eSPI &tft, double x, double y, byte dp, double xlo, double xhi, double xinc, double ylo, double yhi, double yinc, char *title, char *xlabel, char *ylabel, - boolean &update1, unsigned int color) + bool &update1, unsigned int color) { double ydiv, xdiv; double i; diff --git a/examples/480 x 320/Keypad_480x320/Keypad_480x320.ino b/examples/480 x 320/Keypad_480x320/Keypad_480x320.ino index 427cb6a..9614d6a 100644 --- a/examples/480 x 320/Keypad_480x320/Keypad_480x320.ino +++ b/examples/480 x 320/Keypad_480x320/Keypad_480x320.ino @@ -111,7 +111,7 @@ void loop(void) { uint16_t t_x = 0, t_y = 0; // To store the touch coordinates // Pressed will be set true is there is a valid touch on the screen - boolean pressed = tft.getTouch(&t_x, &t_y); + bool pressed = tft.getTouch(&t_x, &t_y); // / Check if any key coordinate boxes contain the touch coordinates for (uint8_t b = 0; b < 15; b++) { diff --git a/examples/480 x 320/TFT_ring_meter/TFT_ring_meter.ino b/examples/480 x 320/TFT_ring_meter/TFT_ring_meter.ino index d4d8c2f..923cb39 100644 --- a/examples/480 x 320/TFT_ring_meter/TFT_ring_meter.ino +++ b/examples/480 x 320/TFT_ring_meter/TFT_ring_meter.ino @@ -26,7 +26,7 @@ uint32_t runTime = -99999; // time for next update int reading = 0; // Value to be displayed int d = 0; // Variable used for the sinewave test waveform -boolean range_error = 0; +bool range_error = 0; int8_t ramp = 1; void setup(void) { @@ -180,7 +180,7 @@ int ringMeter(int value, int vmin, int vmax, int x, int y, int r, const char *un return x + r; } -void drawAlert(int x, int y , int side, boolean draw) +void drawAlert(int x, int y , int side, bool draw) { if (draw && !range_error) { drawIcon(alert, x - alertWidth/2, y - alertHeight/2, alertWidth, alertHeight); diff --git a/examples/Generic/Animated_Eyes_1/eye_functions.ino b/examples/Generic/Animated_Eyes_1/eye_functions.ino index 102ae48..96a583e 100644 --- a/examples/Generic/Animated_Eyes_1/eye_functions.ino +++ b/examples/Generic/Animated_Eyes_1/eye_functions.ino @@ -237,7 +237,7 @@ void frame(uint16_t iScale) // Iris scale (0-1023) // Periodically initiates motion to a new random point, random speed, // holds there for random period until next motion. - static boolean eyeInMotion = false; + static bool eyeInMotion = false; static int16_t eyeOldX = 512, eyeOldY = 512, eyeNewX = 512, eyeNewY = 512; static uint32_t eyeMoveStartTime = 0L; static int32_t eyeMoveDuration = 0L; diff --git a/examples/Generic/Animated_Eyes_2/eye_functions.ino b/examples/Generic/Animated_Eyes_2/eye_functions.ino index 102ae48..96a583e 100644 --- a/examples/Generic/Animated_Eyes_2/eye_functions.ino +++ b/examples/Generic/Animated_Eyes_2/eye_functions.ino @@ -237,7 +237,7 @@ void frame(uint16_t iScale) // Iris scale (0-1023) // Periodically initiates motion to a new random point, random speed, // holds there for random period until next motion. - static boolean eyeInMotion = false; + static bool eyeInMotion = false; static int16_t eyeOldX = 512, eyeOldY = 512, eyeNewX = 512, eyeNewY = 512; static uint32_t eyeMoveStartTime = 0L; static int32_t eyeMoveDuration = 0L; diff --git a/examples/Generic/ESP32_SDcard_jpeg/ESP32_SDcard_jpeg.ino b/examples/Generic/ESP32_SDcard_jpeg/ESP32_SDcard_jpeg.ino index b0e09e2..3c30f1d 100644 --- a/examples/Generic/ESP32_SDcard_jpeg/ESP32_SDcard_jpeg.ino +++ b/examples/Generic/ESP32_SDcard_jpeg/ESP32_SDcard_jpeg.ino @@ -118,8 +118,8 @@ void drawSdJpeg(const char *filename, int xpos, int ypos) { Serial.println("==========================="); // Use one of the following methods to initialise the decoder: - boolean decoded = JpegDec.decodeSdFile(jpegFile); // Pass the SD file handle to the decoder, - //boolean decoded = JpegDec.decodeSdFile(filename); // or pass the filename (String or character array) + bool decoded = JpegDec.decodeSdFile(jpegFile); // Pass the SD file handle to the decoder, + //bool decoded = JpegDec.decodeSdFile(filename); // or pass the filename (String or character array) if (decoded) { // print information about the image to the serial port diff --git a/examples/Generic/ESP8266_uncannyEyes/ESP8266_uncannyEyes.ino b/examples/Generic/ESP8266_uncannyEyes/ESP8266_uncannyEyes.ino index 4d5d4e7..76f46b3 100644 --- a/examples/Generic/ESP8266_uncannyEyes/ESP8266_uncannyEyes.ino +++ b/examples/Generic/ESP8266_uncannyEyes/ESP8266_uncannyEyes.ino @@ -218,7 +218,7 @@ void frame( // Process motion for a single frame of left or right eye // Periodically initiates motion to a new random point, random speed, // holds there for random period until next motion. - static boolean eyeInMotion = false; + static bool eyeInMotion = false; static int32_t eyeOldX=512, eyeOldY=512, eyeNewX=512, eyeNewY=512; static uint32_t eyeMoveStartTime = 0L; static int32_t eyeMoveDuration = 0L; diff --git a/examples/Generic/On_Off_Button/On_Off_Button.ino b/examples/Generic/On_Off_Button/On_Off_Button.ino index 035cf6e..9e057cd 100644 --- a/examples/Generic/On_Off_Button/On_Off_Button.ino +++ b/examples/Generic/On_Off_Button/On_Off_Button.ino @@ -27,7 +27,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library // Repeat calibration if you change the screen rotation. #define REPEAT_CAL false -boolean SwitchOn = false; +bool SwitchOn = false; // Comment out to stop drawing black spots #define BLACK_SPOT diff --git a/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino b/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino index 256e2b3..4abff7f 100644 --- a/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino +++ b/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino @@ -73,7 +73,7 @@ void loop() { uint16_t t_x = 0, t_y = 0; // To store the touch coordinates // Get current touch state and coordinates - boolean pressed = tft.getTouch(&t_x, &t_y); + bool pressed = tft.getTouch(&t_x, &t_y); // Adjust press state of each key appropriately for (uint8_t b = 0; b < NUM_KEYS; b++) { diff --git a/examples/Generic/TFT_Screen_Capture/processing_sketch.ino b/examples/Generic/TFT_Screen_Capture/processing_sketch.ino index 3e71f41..345bb18 100644 --- a/examples/Generic/TFT_Screen_Capture/processing_sketch.ino +++ b/examples/Generic/TFT_Screen_Capture/processing_sketch.ino @@ -49,9 +49,9 @@ String image_type = ".png"; // Lossless compression //String image_type = ".bmp"; // # //String image_type = ".tif"; // # // # -boolean save_border = true; // Save the image with a border # +bool save_border = true; // Save the image with a border # int border = 5; // Border pixel width # -boolean fade = false; // Fade out image after saving # +bool fade = false; // Fade out image after saving # // # int max_images = 100; // Maximum of numbered file images before over-writing files # // # @@ -82,9 +82,9 @@ color frameColor = 42; color buttonStopped = color(255, 0, 0); color buttonRunning = color(128, 204, 206); color buttonDimmed = color(180, 0, 0); -boolean dimmed = false; -boolean running = true; -boolean mouseClick = false; +bool dimmed = false; +bool running = true; +bool mouseClick = false; int[] rgb = new int[3]; // Buffer for the colour bytes int indexRed = 0; // Colour byte index in the array @@ -288,7 +288,7 @@ void flushBuffer() while ( millis() < clearTime ) serial.clear(); } -boolean getSize() +bool getSize() { if ( serial.available() > 6 ) { println(); @@ -371,7 +371,7 @@ void getFilename() else if (inByte == 't') image_type =".tif"; } -boolean unicodeCheck(int unicode) +bool unicodeCheck(int unicode) { if ( unicode >= '0' && unicode <= '9' ) return true; if ( (unicode >= 'A' && unicode <= 'Z' ) || (unicode >= 'a' && unicode <= 'z')) return true; @@ -475,7 +475,7 @@ void percent(float percentage) text(" [ " + (int)percentage + "% ]", 10, height-8); } -boolean fadedImage() +bool fadedImage() { int opacity = frameCount - drawLoopCount; // So we get increasing fade if (fade) diff --git a/examples/Generic/TFT_Screen_Capture/screenServer.ino b/examples/Generic/TFT_Screen_Capture/screenServer.ino index 2924947..82bbbd7 100644 --- a/examples/Generic/TFT_Screen_Capture/screenServer.ino +++ b/examples/Generic/TFT_Screen_Capture/screenServer.ino @@ -48,7 +48,7 @@ // Screen server call with no filename //==================================================================================== // Start a screen dump server (serial or network) - no filename specified -boolean screenServer(void) +bool screenServer(void) { // With no filename the screenshot will be saved with a default name e.g. tft_screen_#.xxx // where # is a number 0-9 and xxx is a file type specified below @@ -59,12 +59,12 @@ boolean screenServer(void) // Screen server call with filename //==================================================================================== // Start a screen dump server (serial or network) - filename specified -boolean screenServer(String filename) +bool screenServer(String filename) { delay(0); // Equivalent to yield() for ESP8266; - boolean result = serialScreenServer(filename); // Screenshot serial port server - //boolean result = wifiScreenServer(filename); // Screenshot WiFi UDP port server (WIP) + bool result = serialScreenServer(filename); // Screenshot serial port server + //bool result = wifiScreenServer(filename); // Screenshot WiFi UDP port server (WIP) delay(0); // Equivalent to yield() @@ -78,13 +78,13 @@ boolean screenServer(String filename) //==================================================================================== // Serial server function that sends the data to the client //==================================================================================== -boolean serialScreenServer(String filename) +bool serialScreenServer(String filename) { // Precautionary receive buffer garbage flush for 50ms uint32_t clearTime = millis() + 50; while ( millis() < clearTime && Serial.read() >= 0) delay(0); // Equivalent to yield() for ESP8266; - boolean wait = true; + bool wait = true; uint32_t lastCmdTime = millis(); // Initialise start of command time-out // Wait for the starting flag with a start time-out diff --git a/examples/Generic/Touch_calibrate/Touch_calibrate.ino b/examples/Generic/Touch_calibrate/Touch_calibrate.ino index 45fa705..92eadb5 100644 --- a/examples/Generic/Touch_calibrate/Touch_calibrate.ino +++ b/examples/Generic/Touch_calibrate/Touch_calibrate.ino @@ -44,7 +44,7 @@ void loop(void) { uint16_t x = 0, y = 0; // To store the touch coordinates // Pressed will be set true is there is a valid touch on the screen - boolean pressed = tft.getTouch(&x, &y); + bool pressed = tft.getTouch(&x, &y); // Draw a white spot at the detected coordinates if (pressed) {