forked from pimoroni/pimoroni-pico
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move scroll_text, show_text, bitmap_1d and set_pixels into C++ library
Move scroll_text into the C++ library and make it support std::string. Move show_bitmap_1d to set_bitmap_1d in the C++ library. Use it as the basis for show_text and scroll_text. Change show_text to set_text since it does not implicitly show the result. Add a new pico-scroll demo to show off the scrolling text functionality.
- Loading branch information
Showing
14 changed files
with
171 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
add_executable( | ||
scroll | ||
demo.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(scroll pico_stdlib pico_scroll) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(scroll) | ||
include(demo.cmake) | ||
include(scroll-text.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_executable( | ||
scroll | ||
demo.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(scroll pico_stdlib pico_scroll) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(scroll) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_executable( | ||
scroll-text | ||
scroll-text.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(scroll-text pico_stdlib pico_scroll) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(scroll-text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
#include "pico/stdlib.h" | ||
|
||
#include "pico_scroll.hpp" | ||
|
||
using namespace pimoroni; | ||
|
||
PicoScroll pico_scroll; | ||
|
||
int main() { | ||
stdio_init_all(); | ||
pico_scroll.init(); | ||
|
||
while(true) { | ||
pico_scroll.scroll_text("Hello World, how are you today?", 64, 100); | ||
sleep_ms(500); | ||
|
||
pico_scroll.set_text("Test", 64); | ||
pico_scroll.update(); | ||
sleep_ms(1000); | ||
|
||
// Set pixels to a chessboard pattern | ||
char pixels[PicoScroll::WIDTH * PicoScroll::HEIGHT] = {}; | ||
|
||
pico_scroll.set_pixels(pixels); | ||
for (int y = 0; y < PicoScroll::HEIGHT; y++) { | ||
for (int x = 0; x < PicoScroll::WIDTH; x++) { | ||
pixels[y * PicoScroll::WIDTH + x] = ((x + y) & 0b1) * 64; | ||
} | ||
} | ||
|
||
pico_scroll.set_pixels(pixels); | ||
pico_scroll.update(); | ||
|
||
sleep_ms(1000); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
add_library(pico_scroll INTERFACE) | ||
|
||
target_sources(pico_scroll INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/pico_scroll.cpp | ||
) | ||
|
||
target_include_directories(pico_scroll INTERFACE ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(pico_scroll INTERFACE pico_stdlib hardware_i2c) | ||
include(pico_scroll.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
|
||
// external font API | ||
int render_text(const char *text, unsigned int nchr, unsigned char *buffer, unsigned int nbfr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.