Skip to content

Commit

Permalink
Enable -Werror -Wall and fix all the things
Browse files Browse the repository at this point in the history
Since MicroPython builds under stricter conditions, this change should help minimise pitfalls when writing/binding drivers.
  • Loading branch information
Gadgetoid committed May 17, 2021
1 parent 3e56dfb commit 7fa9e5b
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 38 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ include_directories(
${CMAKE_CURRENT_LIST_DIR}
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")

add_subdirectory(common)
add_subdirectory(drivers)
add_subdirectory(libraries)
Expand Down
2 changes: 1 addition & 1 deletion examples/breakout_encoder/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void from_hsv(float h, float s, float v, uint8_t &r, uint8_t &g, uint8_t &b) {
void count_changed(int16_t count) {
printf("Count: %d\n", count);
float h = (count % STEPS_PER_REV) / (float)STEPS_PER_REV;
uint8_t r, g, b;
uint8_t r = 0, g = 0, b = 0;
from_hsv(h, 1.0f, 1.0f, r, g, b);
enc.set_led(r, g, b);
}
Expand Down
3 changes: 1 addition & 2 deletions examples/breakout_potentiometer/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int main() {

stdio_init_all();

int16_t count = 0;
if(pot.init()) {
printf("Potentiometer found...\n");

Expand All @@ -50,7 +49,7 @@ int main() {
float percent = pot.read();

printf("Percent: %d\n", (int)(percent * 100));
uint8_t r, g, b;
uint8_t r = 0, g = 0, b = 0;
from_hsv(percent, 1.0f, 1.0f, r, g, b);
pot.set_led(r, g, b);

Expand Down
2 changes: 1 addition & 1 deletion examples/breakout_roundlcd/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BreakoutRoundLCD display(buffer, BG_SPI_FRONT);
constexpr float RADIUS = BreakoutRoundLCD::WIDTH / 2;

Pen from_hsv(float h, float s, float v) {
uint8_t r, g, b;
uint8_t r = 0, g = 0, b = 0;

float i = floor(h * 6.0f);
float f = h * 6.0f - i;
Expand Down
7 changes: 3 additions & 4 deletions examples/breakout_sgp30/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ BreakoutSGP30 sgp30(&i2c);
int main() {
uint8_t prd;
uint16_t eCO2, TVOC;
uint16_t raweCO2, rawTVOC;
uint16_t baseCO2, baseTVOC;
uint16_t rawCO2, rawTVOC;

gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
Expand Down Expand Up @@ -57,8 +56,8 @@ int main() {
sleep_ms(1000 - (100 * prd));
if(prd == 1) {
sgp30.get_air_quality(&eCO2, &TVOC);
sgp30.get_air_quality_raw(&raweCO2, &rawTVOC);
printf("%3d: CO2 %d TVOC %d, raw %d %d\n", j, eCO2, TVOC, raweCO2, rawTVOC);
sgp30.get_air_quality_raw(&rawCO2, &rawTVOC);
printf("%3d: CO2 %d TVOC %d, raw %d %d\n", j, eCO2, TVOC, rawCO2, rawTVOC);
if(j == 30) {
printf("Resetting device\n");
sgp30.soft_reset();
Expand Down
5 changes: 0 additions & 5 deletions examples/pico_display/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ int main() {
// uint16_t dark_green = pico_display.create_pen(10, 100, 10);
// uint16_t blue = pico_display.create_pen(0, 0, 255);

bool a_pressed = false;
bool b_pressed = false;
bool x_pressed = false;
bool y_pressed = false;

struct pt {
float x;
float y;
Expand Down
7 changes: 1 addition & 6 deletions examples/pico_explorer/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ int main() {
pico_explorer.init();
msa301.init();

bool a_pressed = false;
bool b_pressed = false;
bool x_pressed = false;
bool y_pressed = false;

struct pt {
float x;
float y;
Expand Down Expand Up @@ -160,7 +155,7 @@ int main() {
float yoff = cos(i / 20.0f) * 50.0f;
yoff += 120 - (68 / 2);
for(int y = 0; y < 68; y++) {
uint16_t *dest = pico_explorer.frame_buffer + (y * 240);
// uint16_t *dest = pico_explorer.frame_buffer + (y * 240);
uint8_t *src = _binary_fox_tga_start + 18 + (y * 81 * 3);
for(int x = 0; x < 81; x++) {
uint8_t b = *src++;
Expand Down
3 changes: 1 addition & 2 deletions examples/pico_pot_explorer/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ int main() {
pico_explorer.init();
pico_explorer.update();

int16_t count = 0;
if(pot.init()) {
printf("Potentiometer found...\n");

Expand All @@ -55,7 +54,7 @@ int main() {
float percent = pot.read();

printf("Percent: %d\n", (int)(percent * 100));
uint8_t r, g, b;
uint8_t r = 0, g = 0, b = 0;
from_hsv(percent, 1.0f, 1.0f, r, g, b);
pot.set_led(r, g, b);

Expand Down
2 changes: 1 addition & 1 deletion examples/pico_tof_display/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int main() {
bool dist_held = false;

while(true) {
bool a_pressed = ar_button_a.next(i, pico_display.is_pressed(pico_display.A));
// bool a_pressed = ar_button_a.next(i, pico_display.is_pressed(pico_display.A));
bool b_pressed = ar_button_b.next(i, pico_display.is_pressed(pico_display.B));
bool x_pressed = ar_button_x.next(i, pico_display.is_pressed(pico_display.X));
bool y_pressed = ar_button_y.next(i, pico_display.is_pressed(pico_display.Y));
Expand Down
5 changes: 0 additions & 5 deletions examples/pico_unicorn/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ int main() {
uint32_t i = 0;
while(true) {
i = i + 1;
uint8_t j = 0;





if(pico_unicorn.is_pressed(pico_unicorn.A)) { a_pressed = true; }
if(pico_unicorn.is_pressed(pico_unicorn.B)) { b_pressed = true; }
Expand Down
5 changes: 3 additions & 2 deletions examples/pico_unicorn_plasma/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ int main() {
while(true) {
int x1, x2, x3, x4, y1, y2, y3, y4, sx1, sx2, sx3, sx4;
unsigned char x, y;
int8_t value;
uint8_t r, g, b,j,k,l,m;
int8_t value;
uint8_t r = 0, g = 0, b = 0;
uint8_t j, k, l, m;

// Setup a delay to slow the framerate.
// Would be better to read from a timer as some math operations take variable time
Expand Down
12 changes: 6 additions & 6 deletions examples/pico_wireless/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main() {

sleep_ms(1000);

uint8_t r, g, b;
uint8_t r = 0, g = 0, b = 0;
uint8_t a = 0;
while(!wireless.is_pressed(PicoWireless::A)) {
from_hsv((float)a/256.0f, 1, 1, r, g, b);
Expand All @@ -79,15 +79,15 @@ int main() {

printf("firmware version Nina %s\n", wireless.get_fw_version());
uint8_t* mac = wireless.get_mac_address();
printf("mac address ", wireless.get_mac_address()[0]);
for(uint i =0; i < WL_MAC_ADDR_LENGTH; i++) {
printf("mac address ");
for(uint i = 0; i < WL_MAC_ADDR_LENGTH; i++) {
printf("%d:", mac[i]);
}
printf("\n");

printf("starting connection\n");

bool connected = wireless.wifi_set_passphrase(NETWORK, PASSWORD);
wireless.wifi_set_passphrase(NETWORK, PASSWORD);

printf("waiting to establish connection status\n");
while(wireless.get_connection_status() != WL_CONNECTED) {
Expand All @@ -103,8 +103,8 @@ int main() {
wireless.get_gateway_ip(gateway);
printf("gateway address: %d.%d.%d.%d\n", gateway[0], gateway[1], gateway[2], gateway[3]);

printf("SSID = %s\n", wireless.get_current_ssid());
printf("RSSI = %d\n", wireless.get_current_rssi());
printf("SSID = %s\n", wireless.get_current_ssid().c_str());
printf("RSSI = %ld\n", wireless.get_current_rssi());

uint8_t t = 0;
while (true) {
Expand Down
2 changes: 1 addition & 1 deletion examples/pico_wireless/rgb_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int socket_accept(int8_t server_sock) {
}

uint8_t start_server(uint16_t http_port) {
printf("Starting server...\n", NETWORK);
printf("Starting server...\n");
// Get a socket for our server
uint8_t server_sock = wireless.get_socket();
wireless.start_server(http_port, server_sock);
Expand Down
4 changes: 2 additions & 2 deletions examples/pico_wireless/sdcard_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool has_suffix(std::string_view path, std::string_view suffix) {
}

uint8_t start_server(uint16_t http_port) {
printf("Starting server...\n", NETWORK);
printf("Starting server...\n");
// Get a socket for our server
uint8_t server_sock = wireless.get_socket();
wireless.start_server(http_port, server_sock);
Expand Down Expand Up @@ -237,7 +237,7 @@ int main() {
printf("Listing /\n");
f_opendir(dir, "/");
while(f_readdir(dir, &file) == FR_OK && file.fname[0]) {
printf("%s %d\n", file.fname, file.fsize);
printf("%s %lld\n", file.fname, file.fsize);
}
f_closedir(dir);

Expand Down

0 comments on commit 7fa9e5b

Please sign in to comment.