diff --git a/CMakeLists.txt b/CMakeLists.txt index f0d0c58..cf5af44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20) # Change your executable name to something creative! -set(NAME badger-project) +set(NAME badger-2fa) # include the dependencies include(pimoroni_pico_import.cmake) @@ -19,6 +19,6 @@ add_subdirectory(pimoroni-pico) # add_subdirectory() # <- add more dependencies like this # add the project as a subdirectory after bootstrapping -add_subdirectory(programexample) +add_subdirectory(otpgen) # add_subdirectory() # <- add more programs like this diff --git a/programexample/CMakeLists.txt b/otpgen/CMakeLists.txt similarity index 80% rename from programexample/CMakeLists.txt rename to otpgen/CMakeLists.txt index 4ce5fd5..49a1d5c 100644 --- a/programexample/CMakeLists.txt +++ b/otpgen/CMakeLists.txt @@ -1,12 +1,16 @@ # rename your project -project(programexample C CXX) +project(otpgen C CXX) + # Initialize the SDK pico_sdk_init() + # Add your source files add_executable(${PROJECT_NAME} - main.cpp # <-- Add source files here! + main.cpp + topt.cpp + sha1.cpp ) # set pico specific options @@ -21,7 +25,7 @@ pico_enable_stdio_usb(${PROJECT_NAME} 0) target_link_libraries(${PROJECT_NAME} pico_stdlib hardware_spi - badger2040 # <-- List libraries here! + badger2040 ) @@ -30,4 +34,6 @@ pico_enable_stdio_usb(${PROJECT_NAME} 1) pico_add_extra_outputs(${PROJECT_NAME}) # include source directories if needed -include_directories(../pimoroni-pico) +include_directories(../pimoroni-pico ) + + diff --git a/programexample/main.cpp b/programexample/main.cpp deleted file mode 100644 index 51f7585..0000000 --- a/programexample/main.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Example fetched from: -// https://github.com/pimoroni/pimoroni-pico/tree/main/examples/badger2040 - -#include - -#include -#include -#include - -#include "badger2040.hpp" -#include "common/pimoroni_common.hpp" -#include "pico/platform.h" -#include "pico/stdlib.h" -#include "pico/time.h" - -using namespace pimoroni; - -Badger2040 badger; - -uint32_t time() { - absolute_time_t t = get_absolute_time(); - return to_ms_since_boot(t); -} - -std::array font_names = {"sans", "sans_bold", "gothic", - "cursive", "cursive_bold", "serif", - "serif_bold", "serif_italic"}; -int8_t selected_font = 0; - -void draw() { - badger.pen(15); - badger.clear(); - - badger.font("sans"); - for (int i = 0; i < int(font_names.size()); i++) { - std::string name = font_names[i]; - - if (selected_font == i) { - badger.pen(0); - badger.rectangle(0, i * 16, 80, 16); - badger.pen(15); - } else { - badger.pen(0); - } - - badger.text(name, 2, i * 16 + 7, 0.4f); - } - - badger.font(font_names[selected_font]); - badger.thickness(2); - badger.text("The quick", 90, 10, 0.80f); - badger.text("brown fox", 90, 32, 0.80f); - badger.text("jumped over", 90, 54, 0.80f); - badger.text("the lazy dog.", 90, 76, 0.80f); - badger.text("0123456789", 90, 98, 0.80f); - badger.text("!\"£$%^&*()", 90, 120, 0.80f); - badger.thickness(1); - - badger.update(); -} - -int main() { - stdio_init_all(); - - sleep_ms(500); - - printf("\n\n=======\nbadger2040 starting up\n\n"); - - badger.init(); - badger.update_speed(1); - - uint32_t i = 0; - - while (true) { - printf("> drawing.."); - - draw(); - - printf("done!\n"); - - printf("> waiting for a button press.."); - badger.wait_for_press(); - printf("done!\n"); - - if (badger.pressed(badger.DOWN)) { - printf("> down pressed\n"); - selected_font++; - } - - if (badger.pressed(badger.UP)) { - printf("> up pressed\n"); - selected_font--; - } - - if (badger.pressed(badger.C)) { - printf("> C pressed\n"); - badger.halt(); - } - - selected_font = - selected_font < 0 ? int(font_names.size()) - 1 : selected_font; - selected_font = selected_font >= int(font_names.size()) ? 0 : selected_font; - - printf("> newly selected font is %s (%d)\n", - font_names[selected_font].c_str(), selected_font); - - i++; - } -}