Skip to content

Commit

Permalink
Allow building a base video mode version by setting the precompiler d…
Browse files Browse the repository at this point in the history
…efine BASE_VIDEO_MODE. This mode only accepts 30fps and does not allow enabling frame blending or green mode. This is not relevant for most user, but can be useful for live streaming competitions with postprocessed images from unified GBInterceptor settings.
  • Loading branch information
Staacks committed Sep 7, 2024
1 parent f16a41a commit 3c07810
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ pico_generate_pio_header(gb_interceptor

pico_generate_pio_header(gb_interceptor
${CMAKE_CURRENT_LIST_DIR}/jpeg/jpeg_encoding.pio
)
)

#add_compile_definitions(BASE_VIDEO_MODE) #Uncomment for base video mode version with fixed 30fps and no frame blending
6 changes: 6 additions & 0 deletions firmware/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void ledOff() {
}

void checkModeSwitch() {
#ifndef BASE_VIDEO_MODE
if (gpio_get(LED_SWITCH_PIN)) {
if (!modeButtonDebounce) {
modeButtonDebounce = true;
Expand All @@ -75,6 +76,7 @@ void checkModeSwitch() {
} else if (modeButtonDebounce) {
modeButtonDebounce = false;
}
#endif
}

bool static inline isGameBoyOn() {
Expand Down Expand Up @@ -306,7 +308,11 @@ void tud_video_frame_xfer_complete_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx

int tud_video_commit_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, video_probe_and_commit_control_t const *parameters) {
(void)ctl_idx; (void)stm_idx;
#ifdef BASE_VIDEO_MODE
includeChroma = true;
#else
includeChroma = parameters->dwFrameInterval > 200000 /*slower than 50fps*/;
#endif
updateIncludeChroma();
return VIDEO_ERROR_NONE;
}
Expand Down
8 changes: 7 additions & 1 deletion firmware/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#define LED_SWITCH_PIN 1
#define LED_PIN_MASK 0x02

#define VERSION "1.2.0"
#define BASEVERSION "1.2.0"

#ifdef BASE_VIDEO_MODE
#define VERSION BASEVERSION "B"
#else
#define VERSION BASEVERSION
#endif

//On-screen display
#define MODE_INFO_DURATION 100 //Duration of the mode info in frames
Expand Down
4 changes: 4 additions & 0 deletions firmware/ppu.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ uint8_t volatile * lastBuffer = buffer4; //Copy of last back buffer for frame b
uint8_t * backBufferLine = buffer3;
bool readyBufferIsNew = false;

#ifdef BASE_VIDEO_MODE
bool frameBlending = false;
#else
bool frameBlending = true;
#endif

uint lineCycle = 0;
int x = 0; //LX
Expand Down
10 changes: 8 additions & 2 deletions firmware/usb_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ void setUniqueSerial();
#define FRAME_WIDTH 160*8
#define FRAME_HEIGHT 144*8

#ifdef BASE_VIDEO_MODE
#define MIN_FRAME_INTERVAL 333333
#else
#define MIN_FRAME_INTERVAL 166666
#endif

#if CFG_TUD_CDC == 1
enum {
ITF_NUM_VIDEO_CONTROL,
Expand Down Expand Up @@ -77,7 +83,7 @@ enum {
TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT(/*bFrameIndex */ 1, 0, _width, _height, \
FRAME_SIZE * 8 * 30, FRAME_SIZE_NO_CHROMA * 8 * 60, \
FRAME_SIZE, \
333333, 166666, 333333, 166667), /*default 30fps, 30fps, 60fps*/ \
333333, MIN_FRAME_INTERVAL, 333333, 166667), /*default 30fps, 30fps, 60fps*/ \
TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING(VIDEO_COLOR_PRIMARIES_BT709, VIDEO_COLOR_XFER_CH_BT709, VIDEO_COLOR_COEF_SMPTE170M), /* VS alt 1 */ \
TUD_VIDEO_DESC_STD_VS(ITF_NUM_VIDEO_STREAMING, 1, 1, _stridx), /* EP */ \
TUD_VIDEO_DESC_EP_ISO(_epin, _epsize, 1)
Expand All @@ -103,7 +109,7 @@ enum {
TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT(/*bFrameIndex */ 1, 0, _width, _height, \
FRAME_SIZE * 8 * 30, FRAME_SIZE_NO_CHROMA * 8 * 60, \
FRAME_SIZE, \
333333, 166666, 333333, 166667), /*default 30fps, 30fps, 60fps*/ \
333333, MIN_FRAME_INTERVAL, 333333, 166667), /*default 30fps, 30fps, 60fps*/ \
TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING(VIDEO_COLOR_PRIMARIES_BT709, VIDEO_COLOR_XFER_CH_BT709, VIDEO_COLOR_COEF_SMPTE170M), /* VS alt 1 */ \
TUD_VIDEO_DESC_EP_BULK(_epin, _epsize, 1)

Expand Down

0 comments on commit 3c07810

Please sign in to comment.