update cmake build config

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
2022-10-05 01:01:08 +05:30
parent 94d872efc0
commit b08233b09b
3 changed files with 12 additions and 115 deletions

View File

@@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
# Change your executable name to something creative! # Change your executable name to something creative!
set(NAME badger-project) set(NAME badger-2fa)
# include the dependencies # include the dependencies
include(pimoroni_pico_import.cmake) include(pimoroni_pico_import.cmake)
@@ -19,6 +19,6 @@ add_subdirectory(pimoroni-pico)
# add_subdirectory(<dependency-directory-name>) # <- add more dependencies like this # add_subdirectory(<dependency-directory-name>) # <- add more dependencies like this
# add the project as a subdirectory after bootstrapping # add the project as a subdirectory after bootstrapping
add_subdirectory(programexample) add_subdirectory(otpgen)
# add_subdirectory(<program-directory-name>) # <- add more programs like this # add_subdirectory(<program-directory-name>) # <- add more programs like this

View File

@@ -1,12 +1,16 @@
# rename your project # rename your project
project(programexample C CXX) project(otpgen C CXX)
# Initialize the SDK # Initialize the SDK
pico_sdk_init() pico_sdk_init()
# Add your source files # Add your source files
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
main.cpp # <-- Add source files here! main.cpp
topt.cpp
sha1.cpp
) )
# set pico specific options # set pico specific options
@@ -21,7 +25,7 @@ pico_enable_stdio_usb(${PROJECT_NAME} 0)
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
pico_stdlib pico_stdlib
hardware_spi hardware_spi
badger2040 # <-- List libraries here! badger2040
) )
@@ -30,4 +34,6 @@ pico_enable_stdio_usb(${PROJECT_NAME} 1)
pico_add_extra_outputs(${PROJECT_NAME}) pico_add_extra_outputs(${PROJECT_NAME})
# include source directories if needed # include source directories if needed
include_directories(../pimoroni-pico) include_directories(../pimoroni-pico )

View File

@@ -1,109 +0,0 @@
// Example fetched from:
// https://github.com/pimoroni/pimoroni-pico/tree/main/examples/badger2040
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <string>
#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<std::string, 8> 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++;
}
}