Skip to content

Commit

Permalink
fix case of PICO_SCANVIDEO_48MHZ and fix test_pattern for lower bit d…
Browse files Browse the repository at this point in the history
…epths
  • Loading branch information
kilograham committed May 17, 2022
1 parent e551a2d commit f0ce80c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 11 deletions.
5 changes: 5 additions & 0 deletions audio/sine_wave/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ if (TARGET pico_audio_i2s)
PICO_AUDIO_I2S_MONO_INPUT=1
#define for our example code
USE_AUDIO_I2S=1
# PICO_AUDIO_I2S_DATA_PIN=22
# PICO_AUDIO_I2S_CLOCK_PIN_BASE=23
# PICO_DEFAULT_UART=0
# PICO_DEFAULT_UART_TX_PIN=28
# PICO_DEFAULT_UART_RX_PIN=29
)
# create map/bin/hex file etc.
pico_add_extra_outputs(sine_wave_i2s)
Expand Down
5 changes: 5 additions & 0 deletions audio/sine_wave/sine_wave.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

#include "pico/audio_i2s.h"

#if PICO_ON_DEVICE
#include "pico/binary_info.h"
bi_decl(bi_3pins_with_names(PICO_AUDIO_I2S_DATA_PIN, "I2S DIN", PICO_AUDIO_I2S_CLOCK_PIN_BASE, "I2S BCK", PICO_AUDIO_I2S_CLOCK_PIN_BASE+1, "I2S LRCK"));
#endif

#elif USE_AUDIO_PWM
#include "pico/audio_pwm.h"
#elif USE_AUDIO_SPDIF
Expand Down
2 changes: 1 addition & 1 deletion scanvideo/demo1/demo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ int main(void) {

gpio_put(27, 0);
#if PICO_ON_DEVICE && !PICO_ON_FPGA
#if PICO_SCANVIDEO_48MHz
#if PICO_SCANVIDEO_48MHZ
/* set to double frequency 48Mhz for some examples which were written for a higher clock speed */
set_sys_clock_khz(96000, true);
#endif
Expand Down
2 changes: 1 addition & 1 deletion scanvideo/hscroll_dma_tiles/hscroll_dma_tiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void go_core1(void (*execute)()) {
}

int main(void) {
#if PICO_SCANVIDEO_48MHz
#if PICO_SCANVIDEO_48MHZ
set_sys_clock_48mhz();
#endif
setup_default_uart();
Expand Down
2 changes: 1 addition & 1 deletion scanvideo/mario_tiles/mario_tiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ void go_core1(void (*execute)()) {
}

int main(void) {
#if PICO_SCANVIDEO_48MHz
#if PICO_SCANVIDEO_48MHZ
set_sys_clock_48mhz();
#endif
setup_default_uart();
Expand Down
2 changes: 1 addition & 1 deletion scanvideo/scanvideo_minimal/scanvideo_minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void render_scanline(struct scanvideo_scanline_buffer *dest, int core) {


int main(void) {
#if PICO_SCANVIDEO_48MHz
#if PICO_SCANVIDEO_48MHZ
set_sys_clock_48mhz();
#endif
// Re init uart now that clk_peri has changed
Expand Down
2 changes: 1 addition & 1 deletion scanvideo/sprite_demo/sprite_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int main(void) {
sleep_ms(10);
set_sys_clock_khz(400000, true);
#else
#if PICO_SCANVIDEO_48MHz
#if PICO_SCANVIDEO_48MHZ
set_sys_clock_khz(192000, true);
#else
set_sys_clock_khz(200000, true);
Expand Down
11 changes: 5 additions & 6 deletions scanvideo/test_pattern/test_pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,18 @@ int main(void) {
void draw_color_bar(scanvideo_scanline_buffer_t *buffer) {
// figure out 1/32 of the color value
uint line_num = scanvideo_scanline_number(buffer->scanline_id);
int32_t color_step = 1 + (line_num * 7 / vga_mode.height);
color_step = PICO_SCANVIDEO_PIXEL_FROM_RGB5(color_step & 1u, (color_step >> 1u) & 1u, (color_step >> 2u) & 1u);
if (invert) color_step = -color_step;
uint32_t primary_color = 1u + (line_num * 7 / vga_mode.height);
uint32_t color_mask = PICO_SCANVIDEO_PIXEL_FROM_RGB5(0x1f * (primary_color & 1u), 0x1f * ((primary_color >> 1u) & 1u), 0x1f * ((primary_color >> 2u) & 1u));
uint bar_width = vga_mode.width / 32;

uint16_t *p = (uint16_t *) buffer->data;
int32_t color = invert ? PICO_SCANVIDEO_PIXEL_FROM_RGB8(255, 255, 255) : 0;

uint32_t invert_bits = invert ? PICO_SCANVIDEO_PIXEL_FROM_RGB5(0x1f,0x1f,0x1f) : 0;
for (uint bar = 0; bar < 32; bar++) {
*p++ = COMPOSABLE_COLOR_RUN;
*p++ = color;
uint32_t color = PICO_SCANVIDEO_PIXEL_FROM_RGB5(bar, bar, bar);
*p++ = (color & color_mask) ^ invert_bits;
*p++ = bar_width - 3;
color += color_step;
}

// 32 * 3, so we should be word aligned
Expand Down

0 comments on commit f0ce80c

Please sign in to comment.