static void osd_write_arrow(int8_t dir_to_goal) { int16_t d = dir_to_goal - 8; if (d < 0) d += 256; d = (15 - (d/16)) * 2; osd_spi_write(0x04,1); // DMM: Enable auto-increment mode osd_spi_write_byte(0x50 + d); osd_spi_write_byte(0x51 + d); osd_spi_write_byte(0xFF); }
void osd_print(int8_t *str) { osd_spi_write(0x04,1); // DMM: Enable auto-increment mode while (*str) { osd_spi_write_byte((*str) - 60); str++; } osd_spi_write_byte(0xFF); // Disables auto-increment mode when sending 0xFF at the end of a string }
void osd_write_arrow( signed char dir_to_goal ) { int d = dir_to_goal - 8; if (d < 0) d += 256 ; d = (15 - (d/16)) * 2 ; osd_spi_write(0x04,1) ; // DMM: Enable auto-increment mode osd_spi_write_byte(0x50 + d) ; osd_spi_write_byte(0x51 + d) ; osd_spi_write_byte(0xFF) ; return ; }
void osd_run_step( void ) { boolean osd_on = (OSD_MODE_SWITCH_INPUT_CHANNEL == CHANNEL_UNUSED || udb_pwIn[OSD_MODE_SWITCH_INPUT_CHANNEL] >= 3000 || !udb_flags._.radio_on) ; int countdown = 0 ; if (!dcm_flags._.init_finished && udb_heartbeat_counter < 100) { countdown = 100 - udb_heartbeat_counter ; } if (countdown == 61) { osd_spi_write_byte(0xFF) ; // Terminate sending a string, in case that was happening (Prep for reset) } else if (countdown == 60) { osd_spi_write(0x0, 0x02) ; // VM0: Reset the OSD } else if (countdown == 48) { osd_spi_write(0x04, 0) ; // DMM set to 0 } else if (countdown < 48) { if (!osd_was_on && osd_on) { #if (OSD_VIDEO_FORMAT == OSD_NTSC) osd_spi_write(0x0, 0x08) ; // VM0: enable display of OSD image, NTSC #else osd_spi_write(0x0, 0x48) ; // VM0: enable display of OSD image, PAL #endif osd_phase = 0 ; osd_setup_screen() ; osd_was_on = 1 ; } else if (osd_was_on && !osd_on) // just turned off { osd_spi_write(0x04, 4) ; // DMM set to 6 (Blank screen) #if (OSD_VIDEO_FORMAT == OSD_NTSC) osd_spi_write(0x0, 0x00) ; // VM0: disable display of OSD image, NTSC #else osd_spi_write(0x0, 0x40) ; // VM0: disable display of OSD image, PAL #endif osd_was_on = 0 ; } if (osd_on) { osd_update_values() ; osd_phase = (osd_phase+1) % 4 ; } } return ; }
void osd_spi_write_string(const unsigned char *str) { osd_spi_write(0x04,1) ; // DMM: Enable auto-increment mode while (1) { osd_spi_write_byte(*str) ; // Disableble auto-increment mode when sending 0xFF at the end of a string if (*str == 0xFF) break ; str++ ; } return ; }
// Called every 1/40 second at low priority void udb_heartbeat_40hz_callback(void) { if (udb_heartbeat_counter % 20 == 0) { if (charPosition == 256 && !didDisplay) { LED_GREEN = LED_ON; LED_GREEN = LED_ON; osd_spi_write(0x04, 0); // DMM set to 0 #if (OSD_VIDEO_FORMAT == OSD_NTSC) osd_spi_write(0x0, 0x08); // VM0: enable display of OSD image, NTSC #else osd_spi_write(0x0, 0x48); // VM0: enable display of OSD image, PAL #endif int row; for (row = 0; row < 11; row++) { osd_spi_write_location(OSD_LOC(row + 1, 3)); osd_spi_write(0x04, 1); // DMM: Enable auto-increment mode int col; for (col = 0; col < 24; col++) { osd_spi_write_byte(row * 24 + col); } osd_spi_write_byte(0xFF); didDisplay = 1; } } else { udb_led_toggle(LED_RED); } } }
void osd_print(int8_t *str) { // uint8_t ch; unsigned short ch; osd_spi_write(0x04,1); // DMM: Enable auto-increment mode SPIxSTATbits.SPIEN = 0; // disable the SPI module SPIxCON1bits.MODE16 = 1; SPIxSTATbits.SPIEN = 1; // enable the SPI module OSD_CS = 0; // Set active-low CS low to start the SPI cycle while (*str) { if (*str == ' ') { ch = 138; } else { // ch = ((*str) - 60); // write the data out to the SPI peripheral ch = ((*str) + 42); // write the data out to the SPI peripheral } ch = ch * 256; // OSD_CS = 0; // Set active-low CS low to start the SPI cycle // spi_write_raw_fast(ch); spi_write_raw_short(ch); // spi_write_raw_fast(0); // OSD_CS = 1; // Set active-low CS low to start the SPI cycle str++; } OSD_CS = 1; // Set active-low CS high to end the SPI cycle SPIxSTATbits.SPIEN = 0; // disable the SPI module SPIxCON1bits.MODE16 = 0; SPIxSTATbits.SPIEN = 1; // enable the SPI module osd_spi_write_byte(0xFF); // Disables auto-increment mode }
void osd_run_step(void) { boolean osd_on = (OSD_MODE_SWITCH_INPUT_CHANNEL == CHANNEL_UNUSED || udb_pwIn[OSD_MODE_SWITCH_INPUT_CHANNEL] >= 3000 || !udb_flags._.radio_on); int16_t countdown = 0; if (!dcm_flags._.init_finished && udb_heartbeat_counter < 100) { countdown = 100 - udb_heartbeat_counter; } if (countdown == 61) { osd_spi_write_byte(0xFF); // Terminate sending a string, in case that was happening (Prep for reset) } else if (countdown == 60) { osd_spi_write(0x0, 0x02); // VM0: Reset the OSD } else if (countdown == 48) { osd_spi_write(0x04, 0); // DMM set to 0 } else if (countdown < 48) { if (!osd_was_on && osd_on) { #if (OSD_VIDEO_FORMAT == OSD_NTSC) osd_spi_write(0x0, 0x08); // VM0: enable display of OSD image, NTSC #else osd_spi_write(0x0, 0x48); // VM0: enable display of OSD image, PAL #endif osd_phase = 0; osd_setup_screen(); osd_was_on = 1; } else if (osd_was_on && !osd_on) // just turned off { osd_spi_write(0x04, 4); // DMM set to 6 (Blank screen) #if (OSD_VIDEO_FORMAT == OSD_NTSC) osd_spi_write(0x0, 0x00); // VM0: disable display of OSD image, NTSC #else osd_spi_write(0x0, 0x40); // VM0: disable display of OSD image, PAL #endif osd_was_on = 0; } if (osd_on) { if (!osd_phase) { osd_reset_cnt++; } if (!osd_reset_cnt) { osd_spi_write(MAX7456_DMM, 0x04); // DMM set to clear display memory #if (OSD_VIDEO_FORMAT == OSD_NTSC) osd_spi_write(0x0, 0x08); // VM0: enable display of OSD image, NTSC #else osd_spi_write(0x0, 0x48); // VM0: enable display of OSD image, PAL #endif osd_setup_screen(); } else { // work around for a bug whereby the offsets randomly get set to zero osd_spi_write(MAX7456_VOS, OSD_VERTICAL_OFFSET); osd_spi_write(MAX7456_HOS, OSD_HORIZONTAL_OFFSET); osd_update_values(); osd_phase = (osd_phase+1) % 4; } } } }
void osd_spi_write_number(long val, char num_digits, char num_flags, char header, char footer) { boolean startWriting = 0 ; long d; osd_spi_write(0x04,1) ; // DMM: Enable auto-increment mode if (header) osd_spi_write_byte(header) ; if (num_flags & NUM_FLAG_SIGNED) { if (val < 0) { osd_spi_write_byte(0x49) ; // '-' val = -val ; } else osd_spi_write_byte(0x00) ; // ' ' } switch (num_digits) { case 0: case 10: d = (val / 1000000000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*1000000000 ; case 9: d = (val / 100000000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*100000000 ; case 8: d = (val / 10000000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*10000000 ; case 7: d = (val / 1000000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*1000000 ; case 6: d = (val / 100000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*100000 ; case 5: d = (val / 10000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*10000 ; case 4: d = (val / 1000) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*1000 ; case 3: d = (val / 100) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*100 ; case 2: d = (val / 10) ; if (d) startWriting = 1 ; if (startWriting) osd_spi_write_byte((d) ? 0x80 + d : 0x8A) ; else if (num_digits && (num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x8A) ; else if (num_digits && !(num_flags & NUM_FLAG_ZERO_PADDED)) osd_spi_write_byte(0x00) ; val -= d*10 ; case 1: osd_spi_write_byte((val) ? 0x80 + val : 0x8A) ; } if (footer) osd_spi_write_byte(footer) ; if (num_digits == 0) osd_spi_write_byte(0x00) ; osd_spi_write_byte(0xFF) ; // Disableble auto-increment mode return ; }