kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Enable -Werror -Wall and fix all the things
Since MicroPython builds under stricter conditions, this change should help minimise pitfalls when writing/binding drivers.pull/129/head
rodzic
3e56dfb14c
commit
7fa9e5bdca
|
@ -32,6 +32,8 @@ include_directories(
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||||
|
|
||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
add_subdirectory(drivers)
|
add_subdirectory(drivers)
|
||||||
add_subdirectory(libraries)
|
add_subdirectory(libraries)
|
||||||
|
|
|
@ -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) {
|
void count_changed(int16_t count) {
|
||||||
printf("Count: %d\n", count);
|
printf("Count: %d\n", count);
|
||||||
float h = (count % STEPS_PER_REV) / (float)STEPS_PER_REV;
|
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);
|
from_hsv(h, 1.0f, 1.0f, r, g, b);
|
||||||
enc.set_led(r, g, b);
|
enc.set_led(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ int main() {
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
int16_t count = 0;
|
|
||||||
if(pot.init()) {
|
if(pot.init()) {
|
||||||
printf("Potentiometer found...\n");
|
printf("Potentiometer found...\n");
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ int main() {
|
||||||
float percent = pot.read();
|
float percent = pot.read();
|
||||||
|
|
||||||
printf("Percent: %d\n", (int)(percent * 100));
|
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);
|
from_hsv(percent, 1.0f, 1.0f, r, g, b);
|
||||||
pot.set_led(r, g, b);
|
pot.set_led(r, g, b);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ BreakoutRoundLCD display(buffer, BG_SPI_FRONT);
|
||||||
constexpr float RADIUS = BreakoutRoundLCD::WIDTH / 2;
|
constexpr float RADIUS = BreakoutRoundLCD::WIDTH / 2;
|
||||||
|
|
||||||
Pen from_hsv(float h, float s, float v) {
|
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 i = floor(h * 6.0f);
|
||||||
float f = h * 6.0f - i;
|
float f = h * 6.0f - i;
|
||||||
|
|
|
@ -19,8 +19,7 @@ BreakoutSGP30 sgp30(&i2c);
|
||||||
int main() {
|
int main() {
|
||||||
uint8_t prd;
|
uint8_t prd;
|
||||||
uint16_t eCO2, TVOC;
|
uint16_t eCO2, TVOC;
|
||||||
uint16_t raweCO2, rawTVOC;
|
uint16_t rawCO2, rawTVOC;
|
||||||
uint16_t baseCO2, baseTVOC;
|
|
||||||
|
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
@ -57,8 +56,8 @@ int main() {
|
||||||
sleep_ms(1000 - (100 * prd));
|
sleep_ms(1000 - (100 * prd));
|
||||||
if(prd == 1) {
|
if(prd == 1) {
|
||||||
sgp30.get_air_quality(&eCO2, &TVOC);
|
sgp30.get_air_quality(&eCO2, &TVOC);
|
||||||
sgp30.get_air_quality_raw(&raweCO2, &rawTVOC);
|
sgp30.get_air_quality_raw(&rawCO2, &rawTVOC);
|
||||||
printf("%3d: CO2 %d TVOC %d, raw %d %d\n", j, eCO2, TVOC, raweCO2, rawTVOC);
|
printf("%3d: CO2 %d TVOC %d, raw %d %d\n", j, eCO2, TVOC, rawCO2, rawTVOC);
|
||||||
if(j == 30) {
|
if(j == 30) {
|
||||||
printf("Resetting device\n");
|
printf("Resetting device\n");
|
||||||
sgp30.soft_reset();
|
sgp30.soft_reset();
|
||||||
|
|
|
@ -82,11 +82,6 @@ int main() {
|
||||||
// uint16_t dark_green = pico_display.create_pen(10, 100, 10);
|
// uint16_t dark_green = pico_display.create_pen(10, 100, 10);
|
||||||
// uint16_t blue = pico_display.create_pen(0, 0, 255);
|
// 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 {
|
struct pt {
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
|
|
@ -58,11 +58,6 @@ int main() {
|
||||||
pico_explorer.init();
|
pico_explorer.init();
|
||||||
msa301.init();
|
msa301.init();
|
||||||
|
|
||||||
bool a_pressed = false;
|
|
||||||
bool b_pressed = false;
|
|
||||||
bool x_pressed = false;
|
|
||||||
bool y_pressed = false;
|
|
||||||
|
|
||||||
struct pt {
|
struct pt {
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
@ -160,7 +155,7 @@ int main() {
|
||||||
float yoff = cos(i / 20.0f) * 50.0f;
|
float yoff = cos(i / 20.0f) * 50.0f;
|
||||||
yoff += 120 - (68 / 2);
|
yoff += 120 - (68 / 2);
|
||||||
for(int y = 0; y < 68; y++) {
|
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);
|
uint8_t *src = _binary_fox_tga_start + 18 + (y * 81 * 3);
|
||||||
for(int x = 0; x < 81; x++) {
|
for(int x = 0; x < 81; x++) {
|
||||||
uint8_t b = *src++;
|
uint8_t b = *src++;
|
||||||
|
|
|
@ -44,7 +44,6 @@ int main() {
|
||||||
pico_explorer.init();
|
pico_explorer.init();
|
||||||
pico_explorer.update();
|
pico_explorer.update();
|
||||||
|
|
||||||
int16_t count = 0;
|
|
||||||
if(pot.init()) {
|
if(pot.init()) {
|
||||||
printf("Potentiometer found...\n");
|
printf("Potentiometer found...\n");
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ int main() {
|
||||||
float percent = pot.read();
|
float percent = pot.read();
|
||||||
|
|
||||||
printf("Percent: %d\n", (int)(percent * 100));
|
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);
|
from_hsv(percent, 1.0f, 1.0f, r, g, b);
|
||||||
pot.set_led(r, g, b);
|
pot.set_led(r, g, b);
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ int main() {
|
||||||
bool dist_held = false;
|
bool dist_held = false;
|
||||||
|
|
||||||
while(true) {
|
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 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 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));
|
bool y_pressed = ar_button_y.next(i, pico_display.is_pressed(pico_display.Y));
|
||||||
|
|
|
@ -40,11 +40,6 @@ int main() {
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
i = i + 1;
|
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.A)) { a_pressed = true; }
|
||||||
if(pico_unicorn.is_pressed(pico_unicorn.B)) { b_pressed = true; }
|
if(pico_unicorn.is_pressed(pico_unicorn.B)) { b_pressed = true; }
|
||||||
|
|
|
@ -103,7 +103,8 @@ int main() {
|
||||||
int x1, x2, x3, x4, y1, y2, y3, y4, sx1, sx2, sx3, sx4;
|
int x1, x2, x3, x4, y1, y2, y3, y4, sx1, sx2, sx3, sx4;
|
||||||
unsigned char x, y;
|
unsigned char x, y;
|
||||||
int8_t value;
|
int8_t value;
|
||||||
uint8_t r, g, b,j,k,l,m;
|
uint8_t r = 0, g = 0, b = 0;
|
||||||
|
uint8_t j, k, l, m;
|
||||||
|
|
||||||
// Setup a delay to slow the framerate.
|
// Setup a delay to slow the framerate.
|
||||||
// Would be better to read from a timer as some math operations take variable time
|
// Would be better to read from a timer as some math operations take variable time
|
||||||
|
|
|
@ -66,7 +66,7 @@ int main() {
|
||||||
|
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
|
|
||||||
uint8_t r, g, b;
|
uint8_t r = 0, g = 0, b = 0;
|
||||||
uint8_t a = 0;
|
uint8_t a = 0;
|
||||||
while(!wireless.is_pressed(PicoWireless::A)) {
|
while(!wireless.is_pressed(PicoWireless::A)) {
|
||||||
from_hsv((float)a/256.0f, 1, 1, r, g, b);
|
from_hsv((float)a/256.0f, 1, 1, r, g, b);
|
||||||
|
@ -79,7 +79,7 @@ int main() {
|
||||||
|
|
||||||
printf("firmware version Nina %s\n", wireless.get_fw_version());
|
printf("firmware version Nina %s\n", wireless.get_fw_version());
|
||||||
uint8_t* mac = wireless.get_mac_address();
|
uint8_t* mac = wireless.get_mac_address();
|
||||||
printf("mac address ", wireless.get_mac_address()[0]);
|
printf("mac address ");
|
||||||
for(uint i = 0; i < WL_MAC_ADDR_LENGTH; i++) {
|
for(uint i = 0; i < WL_MAC_ADDR_LENGTH; i++) {
|
||||||
printf("%d:", mac[i]);
|
printf("%d:", mac[i]);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ int main() {
|
||||||
|
|
||||||
printf("starting connection\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");
|
printf("waiting to establish connection status\n");
|
||||||
while(wireless.get_connection_status() != WL_CONNECTED) {
|
while(wireless.get_connection_status() != WL_CONNECTED) {
|
||||||
|
@ -103,8 +103,8 @@ int main() {
|
||||||
wireless.get_gateway_ip(gateway);
|
wireless.get_gateway_ip(gateway);
|
||||||
printf("gateway address: %d.%d.%d.%d\n", gateway[0], gateway[1], gateway[2], gateway[3]);
|
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("SSID = %s\n", wireless.get_current_ssid().c_str());
|
||||||
printf("RSSI = %d\n", wireless.get_current_rssi());
|
printf("RSSI = %ld\n", wireless.get_current_rssi());
|
||||||
|
|
||||||
uint8_t t = 0;
|
uint8_t t = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ int socket_accept(int8_t server_sock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t start_server(uint16_t http_port) {
|
uint8_t start_server(uint16_t http_port) {
|
||||||
printf("Starting server...\n", NETWORK);
|
printf("Starting server...\n");
|
||||||
// Get a socket for our server
|
// Get a socket for our server
|
||||||
uint8_t server_sock = wireless.get_socket();
|
uint8_t server_sock = wireless.get_socket();
|
||||||
wireless.start_server(http_port, server_sock);
|
wireless.start_server(http_port, server_sock);
|
||||||
|
|
|
@ -103,7 +103,7 @@ bool has_suffix(std::string_view path, std::string_view suffix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t start_server(uint16_t http_port) {
|
uint8_t start_server(uint16_t http_port) {
|
||||||
printf("Starting server...\n", NETWORK);
|
printf("Starting server...\n");
|
||||||
// Get a socket for our server
|
// Get a socket for our server
|
||||||
uint8_t server_sock = wireless.get_socket();
|
uint8_t server_sock = wireless.get_socket();
|
||||||
wireless.start_server(http_port, server_sock);
|
wireless.start_server(http_port, server_sock);
|
||||||
|
@ -237,7 +237,7 @@ int main() {
|
||||||
printf("Listing /\n");
|
printf("Listing /\n");
|
||||||
f_opendir(dir, "/");
|
f_opendir(dir, "/");
|
||||||
while(f_readdir(dir, &file) == FR_OK && file.fname[0]) {
|
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);
|
f_closedir(dir);
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue