kopia lustrzana https://github.com/pimoroni/pimoroni-pico
added new function test
rodzic
302d6ae0eb
commit
95bdd42177
|
@ -1,11 +1,2 @@
|
|||
add_executable(
|
||||
pico_display_demo
|
||||
pico_display_demo.cpp
|
||||
image_data.cpp
|
||||
)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(pico_display_demo pico_stdlib hardware_spi hardware_pwm hardware_dma rgbled pico_display pico_graphics st7789)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(pico_display_demo)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/pico_display_demo.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/function_test.cmake")
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
add_executable(
|
||||
function_test
|
||||
function_test.cpp
|
||||
)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(function_test pico_stdlib rgbled pico_display pico_graphics st7789 button)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(function_test)
|
|
@ -0,0 +1,81 @@
|
|||
#include "pico/stdlib.h"
|
||||
#include "pico_display.hpp"
|
||||
#include "drivers/st7789/st7789.hpp"
|
||||
#include "libraries/pico_graphics/pico_graphics.hpp"
|
||||
#include "rgbled.hpp"
|
||||
#include "button.hpp"
|
||||
|
||||
using namespace pimoroni;
|
||||
|
||||
ST7789 st7789(PicoDisplay::WIDTH, PicoDisplay::HEIGHT, ROTATE_0, false, get_spi_pins(BG_SPI_FRONT));
|
||||
PicoGraphics_PenRGB332 graphics(st7789.width, st7789.height, nullptr);
|
||||
|
||||
RGBLED led(PicoDisplay::LED_R, PicoDisplay::LED_G, PicoDisplay::LED_B);
|
||||
|
||||
int main() {
|
||||
|
||||
// Set the backlight!
|
||||
st7789.set_backlight(255);
|
||||
|
||||
// Pens
|
||||
Pen BLACK = graphics.create_pen(0, 0, 0);
|
||||
Pen GREEN = graphics.create_pen(0, 255, 0);
|
||||
Pen BLUE = graphics.create_pen(0, 0, 255);
|
||||
Pen RED = graphics.create_pen(255, 0, 0);
|
||||
Pen WHITE = graphics.create_pen(255, 255, 255);
|
||||
|
||||
// Buttons
|
||||
Button button_a(12);
|
||||
Button button_b(13);
|
||||
Button button_x(14);
|
||||
Button button_y(15);
|
||||
|
||||
// Title Screen
|
||||
graphics.set_pen(WHITE);
|
||||
graphics.clear();
|
||||
graphics.set_pen(BLACK);
|
||||
graphics.text("Pico Display Test", Point(10, 50), 4);
|
||||
|
||||
|
||||
// Checks buttons and updates screen
|
||||
while(true) {
|
||||
|
||||
if(button_a.read()) {
|
||||
graphics.set_pen(GREEN);
|
||||
graphics.clear();
|
||||
graphics.set_pen(WHITE);
|
||||
graphics.character('A', Point(100, 50), 8);
|
||||
led.set_rgb(0, 255, 0);
|
||||
}
|
||||
|
||||
if(button_b.read()) {
|
||||
graphics.set_pen(BLUE);
|
||||
graphics.clear();
|
||||
graphics.set_pen(WHITE);
|
||||
graphics.character('B', Point(100, 50), 8);
|
||||
led.set_rgb(0, 0, 255);
|
||||
}
|
||||
|
||||
if(button_x.read()) {
|
||||
graphics.set_pen(WHITE);
|
||||
graphics.clear();
|
||||
graphics.set_pen(BLACK);
|
||||
graphics.character('X', Point(100, 50), 8);
|
||||
led.set_rgb(255,255,255);
|
||||
}
|
||||
|
||||
if(button_y.read()) {
|
||||
graphics.set_pen(RED);
|
||||
graphics.clear();
|
||||
graphics.set_pen(WHITE);
|
||||
graphics.character('Y', Point(100, 50), 8);
|
||||
led.set_rgb(255, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
st7789.update(&graphics);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
add_executable(
|
||||
pico_display_demo
|
||||
pico_display_demo.cpp
|
||||
image_data.cpp
|
||||
)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(pico_display_demo pico_stdlib hardware_spi hardware_pwm hardware_dma rgbled pico_display pico_graphics st7789)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(pico_display_demo)
|
Ładowanie…
Reference in New Issue