Skip to content

Commit

Permalink
Merge pull request #31 from RobertDaleSmith/console-loopy
Browse files Browse the repository at this point in the history
feature(loopy): implements loopy console
  • Loading branch information
RobertDaleSmith authored Feb 4, 2024
2 parents ee19892 + 5bd8095 commit 3e62fd7
Show file tree
Hide file tree
Showing 6 changed files with 523 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ add_executable(usbretro_pce) # For the usbretro_pce target
add_executable(usbretro_ngc) # For the usbretro_ngc target
add_executable(usbretro_xb1) # For the usbretro_xb1 target
add_executable(usbretro_nuon) # For the usbretro_nuon target
add_executable(usbretro_loopy) # For the usbretro_loopy target

target_compile_definitions(usbretro_pce PRIVATE CONFIG_PCE=1)
target_compile_definitions(usbretro_ngc PRIVATE CONFIG_NGC=1)
target_compile_definitions(usbretro_xb1 PRIVATE CONFIG_XB1=1)
target_compile_definitions(usbretro_nuon PRIVATE CONFIG_NUON=1)
target_compile_definitions(usbretro_loopy PRIVATE CONFIG_LOOPY=1)

target_compile_options(usbretro_pce PRIVATE -O3) # Set optimization level to O3 for your_target
target_compile_options(usbretro_ngc PRIVATE -O3) # Set optimization level to O3 for your_target
target_compile_options(usbretro_xb1 PRIVATE -O3) # Set optimization level to O3 for your_target
target_compile_options(usbretro_nuon PRIVATE -O3) # Set optimization level to O3 for your_target
target_compile_options(usbretro_loopy PRIVATE -O3) # Set optimization level to O3 for your_target

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Og")
Expand All @@ -42,6 +45,7 @@ pico_add_extra_outputs(usbretro_pce)
pico_add_extra_outputs(usbretro_ngc)
pico_add_extra_outputs(usbretro_xb1)
pico_add_extra_outputs(usbretro_nuon)
pico_add_extra_outputs(usbretro_loopy)

pico_generate_pio_header(usbretro_pce ${CMAKE_CURRENT_LIST_DIR}/console/pcengine/plex.pio )
pico_generate_pio_header(usbretro_pce ${CMAKE_CURRENT_LIST_DIR}/console/pcengine/clock.pio )
Expand All @@ -53,6 +57,8 @@ pico_generate_pio_header(usbretro_xb1 ${CMAKE_CURRENT_LIST_DIR}/common/ws2812.pi
pico_generate_pio_header(usbretro_nuon ${CMAKE_CURRENT_LIST_DIR}/console/nuon/polyface_read.pio )
pico_generate_pio_header(usbretro_nuon ${CMAKE_CURRENT_LIST_DIR}/console/nuon/polyface_send.pio )
pico_generate_pio_header(usbretro_nuon ${CMAKE_CURRENT_LIST_DIR}/common/ws2812.pio )
pico_generate_pio_header(usbretro_loopy ${CMAKE_CURRENT_LIST_DIR}/console/loopy/loopy.pio )
pico_generate_pio_header(usbretro_loopy ${CMAKE_CURRENT_LIST_DIR}/common/ws2812.pio )

## SET TARGE SOURCES
set(COMMON_SOURCES
Expand Down Expand Up @@ -106,6 +112,11 @@ target_sources(usbretro_nuon PUBLIC # For NUON
${CMAKE_CURRENT_SOURCE_DIR}/console/nuon/nuon.c
)

target_sources(usbretro_loopy PUBLIC # For (Casio) LOOPY
${COMMON_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/console/loopy/loopy.c
)

## SET TARGET INCLUDE DIRS
target_include_directories(usbretro_pce PUBLIC # FOR PCE
${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -128,6 +139,11 @@ target_include_directories(usbretro_nuon PUBLIC # FOR NUON
${CMAKE_CURRENT_SOURCE_DIR}/common
)

target_include_directories(usbretro_loopy PUBLIC # FOR LOOPY
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
)

## SET TARGET LINK LIBS
set(COMMON_LIBRARIES
pico_stdlib
Expand Down Expand Up @@ -156,3 +172,8 @@ target_link_libraries(usbretro_nuon PRIVATE # FOR NUON
${COMMON_LIBRARIES}
pico_bit_ops
)

target_link_libraries(usbretro_loopy PRIVATE # FOR LOOPY
${COMMON_LIBRARIES}
pico_bit_ops
)
23 changes: 23 additions & 0 deletions src/common/ws2812.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ void pattern_purples(uint len, uint t) {
}
}

void pattern_pinks(uint len, uint t) {
int max = 100; // let's not draw too much current!
t %= max;
for (int i = 0; i < len; ++i) {
uint8_t intensity = t; // Adjust the intensity value for a darker effect
put_pixel(urgb_u32(intensity / 2, 0, intensity / 1)); // Dark purple color (red + blue)
if (++t >= max) t = 0;
}
}

void pattern_reds(uint len, uint t) {
int max = 100; // let's not draw too much current!
t %= max;
Expand Down Expand Up @@ -136,6 +146,10 @@ void pattern_purple(uint len, uint t) {
put_pixel(urgb_u32(6, 0, 64)); // purple
}

void pattern_pink(uint len, uint t) {
put_pixel(urgb_u32(64, 20, 32)); // purple
}

void pattern_yellow(uint len, uint t) {
put_pixel(urgb_u32(64, 64, 0)); // yellow
}
Expand Down Expand Up @@ -226,6 +240,14 @@ const struct {
{pattern_green, "Green"}, // 3 controllers
{pattern_purple, "Purple"}, // 4 controllers
{pattern_yellow, "Yellow"}, // 5 controllers
#else
#ifdef CONFIG_LOOPY
{pattern_pinks, "Pinks"}, // 0 controllers
{pattern_pink, "Pink"}, // 1 controller
{pattern_blue, "Blue"}, // 2 controllers
{pattern_red, "Red"}, // 3 controllers
{pattern_green, "Green"}, // 4 controllers
{pattern_yellow, "Yellow"}, // 5 controllers
#else//CONFIG_PCE
{pattern_blues, "Blues"}, // 0 controllers
{pattern_blue, "Blue"}, // 1 controller
Expand All @@ -235,6 +257,7 @@ const struct {
{pattern_yellow, "Yellow"}, // 5 controllers
#endif
#endif
#endif
#endif
{pattern_random, "Random data"},// fun
{pattern_sparkle, "Sparkles"},
Expand Down
Loading

0 comments on commit 3e62fd7

Please sign in to comment.