Switch to stdbool.h

- Add `#include <stdbool.h> to all files previously using the
   `TRUE`/`FALSE` macros
 - Replace all instances of `TRUE`/`FALSE` with `true`/`false`,
   respectively
 - Definitions of `TRUE`/`FALSE` macros retained in wiringPi.h for compatibility.
This commit is contained in:
Connor Gibson
2025-06-01 15:15:56 -07:00
parent 3cf394b206
commit 55e189eda5
42 changed files with 262 additions and 277 deletions

View File

@@ -18,16 +18,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/time.h>
#include <wiringPi.h>
#include <gertboard.h>
#ifndef TRUE
#define TRUE (1==1)
#define FALSE (!TRUE)
#endif
#define B_SIZE 1000
#define S_SIZE 128

View File

@@ -7,17 +7,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <math.h>
#include <wiringPi.h>
#include <piFace.h>
#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#endif
#undef DEBUG
#define NUM_LEDS 8
@@ -244,7 +240,7 @@ void ledOnAction (void)
if (digitalRead (PIFACE) == LOW)
{
chargeCapacitor () ;
ledBargraph (vCap, TRUE) ;
ledBargraph (vCap, true) ;
}
}
@@ -264,7 +260,7 @@ void ledOffAction (void)
if (digitalRead (PIFACE) == LOW)
{
vCap = vCapLast = 0.0 ;
ledBargraph (vCap, FALSE) ;
ledBargraph (vCap, false) ;
// Wait until we release the button
@@ -300,7 +296,7 @@ int main (void)
// LED ON:
(void)ledBargraph (vCap, TRUE) ;
(void)ledBargraph (vCap, true) ;
then = millis () + ledOnTime ;
while (millis () < then)
{
@@ -323,7 +319,7 @@ int main (void)
// LED OFF:
(void)ledBargraph (vCap, FALSE) ;
(void)ledBargraph (vCap, false) ;
then = millis () + ledOffTime ;
while (millis () < then)
{

View File

@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <poll.h>
#include <wiringPi.h>
@@ -32,11 +33,6 @@
#define PIGLOW_BASE 533
#ifndef TRUE
# define TRUE (1==1)
# define FALSE (!TRUE)
#endif
/*
* keypressed: clearKeypressed:

View File

@@ -26,11 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef TRUE
# define TRUE (1==1)
# define FALSE (!TRUE)
#endif
#include <stdbool.h>
#include <wiringPi.h>
#include <piGlow.h>
@@ -81,7 +77,7 @@ int main (int argc, char *argv [])
// Initialise the piGlow devLib
piGlowSetup (FALSE) ;
piGlowSetup (false) ;
if (argc == 1)
failUsage () ;

View File

@@ -35,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
@@ -45,11 +46,6 @@
#include <wiringPi.h>
#include <lcd128x64.h>
#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#endif
double clockRadius ;
double thickness, barLen ;
int maxX, maxY ;
@@ -130,15 +126,15 @@ void drawClockFace (void)
double d, px1, py1, px2, py2 ;
lcd128x64clear (0) ;
lcd128x64circle (0,0, clockRadius, 1, TRUE) ;
lcd128x64circle (0,0, clockRadius - thickness, 0, TRUE) ;
lcd128x64circle (0,0, clockRadius, 1, true) ;
lcd128x64circle (0,0, clockRadius - thickness, 0, true) ;
// The four big indicators for 12,15,30 and 45
lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, TRUE) ; // 12
lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, TRUE) ; // 3
lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, TRUE) ; // 6
lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, TRUE) ; // 9
lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, true) ; // 12
lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, true) ; // 3
lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, true) ; // 6
lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, true) ; // 9
// Smaller 5 and 1 minute ticks

View File

@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
@@ -34,11 +35,6 @@
#include <mcp23017.h>
#include <lcd.h>
#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#endif
// Defines for the Adafruit Pi LCD interface board
@@ -251,7 +247,7 @@ int main (int argc, char *argv[])
{
int colour ;
int cols = 16 ;
int waitForRelease = FALSE ;
int waitForRelease = false ;
struct tm *t ;
time_t tim ;
@@ -287,13 +283,13 @@ int main (int argc, char *argv[])
lcdPuts (lcdHandle, "User Char: ") ;
lcdPutchar (lcdHandle, 2) ;
lcdCursor (lcdHandle, TRUE) ;
lcdCursorBlink (lcdHandle, TRUE) ;
lcdCursor (lcdHandle, true) ;
lcdCursorBlink (lcdHandle, true) ;
waitForEnter () ;
lcdCursor (lcdHandle, FALSE) ;
lcdCursorBlink (lcdHandle, FALSE) ;
lcdCursor (lcdHandle, false) ;
lcdCursorBlink (lcdHandle, false) ;
speedTest () ;
@@ -320,7 +316,7 @@ int main (int argc, char *argv[])
if ((digitalRead (AF_UP) == LOW) || (digitalRead (AF_DOWN) == LOW))
continue ;
else
waitForRelease = FALSE ;
waitForRelease = false ;
}
if (digitalRead (AF_UP) == LOW) // Pushed
@@ -329,7 +325,7 @@ int main (int argc, char *argv[])
if (colour == 8)
colour = 0 ;
setBacklightColour (colour) ;
waitForRelease = TRUE ;
waitForRelease = true ;
}
if (digitalRead (AF_DOWN) == LOW) // Pushed
@@ -338,7 +334,7 @@ int main (int argc, char *argv[])
if (colour == -1)
colour = 7 ;
setBacklightColour (colour) ;
waitForRelease = TRUE ;
waitForRelease = true ;
}
}

View File

@@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
@@ -47,10 +48,6 @@
#include <wiringPi.h>
#include <lcd.h>
#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#endif
static unsigned char newChar [8] =
{
@@ -247,13 +244,13 @@ int main (int argc, char *argv[])
lcdPuts (lcdHandle, "User Char: ") ;
lcdPutchar (lcdHandle, 2) ;
lcdCursor (lcdHandle, TRUE) ;
lcdCursorBlink (lcdHandle, TRUE) ;
lcdCursor (lcdHandle, true) ;
lcdCursorBlink (lcdHandle, true) ;
waitForEnter () ;
lcdCursor (lcdHandle, FALSE) ;
lcdCursorBlink (lcdHandle, FALSE) ;
lcdCursor (lcdHandle, false) ;
lcdCursorBlink (lcdHandle, false) ;
lcdClear (lcdHandle) ;
for (;;)

View File

@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
@@ -36,9 +37,6 @@
#include <wiringPi.h>
#include <wiringPiSPI.h>
#define TRUE (1==1)
#define FALSE (!TRUE)
#define SPI_CHAN 0
#define NUM_TIMES 100
#define MAX_SIZE (1024*1024)
@@ -78,7 +76,7 @@ int main (void)
printf ("| MHz | Size | mS/Trans | TpS | Mb/Sec | Latency mS |\n") ;
printf ("+-------+--------+----------+----------+-----------+------------+\n") ;
spiFail = FALSE ;
spiFail = false ;
spiSetup (speed * 1000000) ;
for (size = 1 ; size <= MAX_SIZE ; size *= 2)
{
@@ -89,7 +87,7 @@ int main (void)
if (wiringPiSPIDataRW (SPI_CHAN, myData, size) == -1)
{
printf ("SPI failure: %s\n", strerror (errno)) ;
spiFail = TRUE ;
spiFail = true ;
break ;
}
end = millis () ;