pimoroni-pico/examples/badger2040/badger2040_image.cpp

65 wiersze
1.2 KiB
C++

2022-01-27 13:07:58 +00:00
#include "pico/stdlib.h"
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include "pico/time.h"
#include "pico/platform.h"
#include "common/pimoroni_common.hpp"
#include "badger2040.hpp"
#include "badger2040_image_demo_images.hpp"
using namespace pimoroni;
Badger2040 badger;
2022-01-27 14:10:31 +00:00
// uint32_t time() {
// absolute_time_t t = get_absolute_time();
// return to_ms_since_boot(t);
// }
2022-01-27 13:07:58 +00:00
int main() {
stdio_init_all();
2022-01-27 14:10:31 +00:00
sleep_ms(20);
2022-01-27 13:07:58 +00:00
printf("\n\n=======\nbadger2040 starting up\n\n");
badger.init();
2022-01-27 14:32:07 +00:00
if(badger.pressed_to_wake(badger.A)) {
2022-01-27 14:10:31 +00:00
printf("> A pressed\n");
badger.image(shaun);
}
2022-01-27 13:07:58 +00:00
2022-01-27 14:32:07 +00:00
else if(badger.pressed_to_wake(badger.B)) {
2022-01-27 14:10:31 +00:00
printf("> B pressed\n");
badger.image(paul);
}
2022-01-27 13:07:58 +00:00
2022-01-27 14:32:07 +00:00
else if(badger.pressed_to_wake(badger.C)) {
2022-01-27 14:10:31 +00:00
printf("> C pressed\n");
badger.image(adam);
}
2022-01-27 13:07:58 +00:00
2022-01-27 14:10:31 +00:00
else {
printf("> No A/B/C key pressed\n");
badger.pen(15);
badger.clear();
2022-01-27 13:07:58 +00:00
2022-01-27 14:10:31 +00:00
badger.pen(0);
badger.font("sans");
badger.text("Press A, B, or C", 15, 65, 1.0f);
}
2022-01-27 13:07:58 +00:00
2022-01-27 14:10:31 +00:00
badger.update();
2022-03-02 21:08:17 +00:00
while (badger.is_busy()) {
sleep_ms(10);
}
2022-01-27 14:10:31 +00:00
badger.halt();
2022-01-27 13:07:58 +00:00
}