namespace a few vars add some #defines for clarity

This commit is contained in:
nathan 2016-06-16 19:16:31 -07:00
parent a960bfd1cd
commit e9868c4e37
7 changed files with 54 additions and 26 deletions

View File

@ -38,6 +38,7 @@
#include "drivers/serial.h"
#include "drivers/gyro_sync.h"
#include "drivers/pwm_output.h"
#include "drivers/max7456.h"
#include "sensors/sensors.h"
#include "sensors/gyro.h"
@ -421,7 +422,7 @@ static void resetConf(void)
#ifdef OSD
featureSet(FEATURE_OSD);
masterConfig.osdProfile.system = 0;
masterConfig.osdProfile.video_system = AUTO;
masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE] = -29;
masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE] = -59;
masterConfig.osdProfile.item_pos[OSD_TIMER] = -39;

View File

@ -31,20 +31,18 @@
#include "drivers/system.h"
#include "max7456.h"
#include "max7456_symbols.h"
#define DISABLE_MAX7456 IOHi(max7456CsPin)
#define ENABLE_MAX7456 IOLo(max7456CsPin)
static IO_t max7456CsPin = IO_NONE;
/** PAL or NTSC, value is number of chars total */
#define VIDEO_BUFFER_CHARS_NTSC 390
#define VIDEO_BUFFER_CHARS_PAL 480
uint16_t max_screen_size;
uint8_t video_signal_type = 0;
uint8_t max7456_lock = 0;
char screen[VIDEO_BUFFER_CHARS_PAL];
char max7456_screen[VIDEO_BUFFER_CHARS_PAL];
uint8_t max7456_send(uint8_t add, uint8_t data) {
@ -53,11 +51,11 @@ uint8_t max7456_send(uint8_t add, uint8_t data) {
}
void max7456_init(uint8_t system) {
void max7456_init(uint8_t video_system) {
uint8_t max_screen_rows;
uint8_t srdata = 0;
uint16_t x;
char buf[30];
char buf[LINE];
#ifdef MAX7456_SPI_CS_PIN
max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN));
@ -83,21 +81,21 @@ void max7456_init(uint8_t system) {
}
// Override detected type: 0-AUTO, 1-PAL, 2-NTSC
switch(system) {
case 1:
switch(video_system) {
case PAL:
video_signal_type = VIDEO_MODE_PAL;
break;
case 2:
case NTSC:
video_signal_type = VIDEO_MODE_NTSC;
break;
}
if (video_signal_type) { //PAL
max_screen_size = VIDEO_BUFFER_CHARS_PAL;
max_screen_rows = 16;
max_screen_rows = VIDEO_LINES_PAL;
} else { // NTSC
max_screen_size = VIDEO_BUFFER_CHARS_NTSC;
max_screen_rows = 13;
max_screen_rows = VIDEO_LINES_NTSC;
}
// set all rows to same charactor black/white level
@ -114,13 +112,13 @@ void max7456_init(uint8_t system) {
x = 160;
for (int i = 1; i < 5; i++) {
for (int j = 3; j < 27; j++)
screen[i * 30 + j] = (char)x++;
max7456_screen[i * LINE + j] = (char)x++;
}
tfp_sprintf(buf, "BF VERSION: %s", FC_VERSION_STRING);
max7456_write_string(buf, 5*30+5);
max7456_write_string("MENU: THRT MID", 6*30+7);
max7456_write_string("YAW RIGHT", 7*30+13);
max7456_write_string("PITCH UP", 8*30+13);
max7456_write_string(buf, LINE06+5);
max7456_write_string("MENU: THRT MID", LINE07+7);
max7456_write_string("YAW RIGHT", LINE08+13);
max7456_write_string("PITCH UP", LINE09+13);
max7456_draw_screen();
}
@ -144,8 +142,8 @@ void max7456_draw_screen(void) {
for (xx = 0; xx < max_screen_size; ++xx) {
max7456_send(MAX7456ADD_DMAH, xx>>8);
max7456_send(MAX7456ADD_DMAL, xx);
max7456_send(MAX7456ADD_DMDI, screen[xx]);
screen[xx] = ' ';
max7456_send(MAX7456ADD_DMDI, max7456_screen[xx]);
max7456_screen[xx] = ' ';
}
DISABLE_MAX7456;
}
@ -159,8 +157,8 @@ void max7456_draw_screen_fast(void) {
max7456_send(MAX7456ADD_DMAL, 0);
max7456_send(MAX7456ADD_DMM, 1);
for (xx = 0; xx < max_screen_size; ++xx) {
max7456_send(MAX7456ADD_DMDI, screen[xx]);
screen[xx] = ' ';
max7456_send(MAX7456ADD_DMDI, max7456_screen[xx]);
max7456_screen[xx] = ' ';
}
max7456_send(MAX7456ADD_DMDI, 0xFF);
max7456_send(MAX7456ADD_DMM, 0);

View File

@ -114,8 +114,36 @@
#define WRITE_NVR 0xA0
#define STATUS_REG_NVR_BUSY 0x20
/** Line multiples, for convenience & one less op at runtime **/
#define LINE 30
#define LINE01 0
#define LINE02 30
#define LINE03 60
#define LINE04 90
#define LINE05 120
#define LINE06 150
#define LINE07 180
#define LINE08 210
#define LINE09 240
#define LINE10 270
#define LINE11 300
#define LINE12 330
#define LINE13 360
#define LINE14 390
#define LINE15 420
#define LINE16 450
/** PAL or NTSC, value is number of chars total */
#define VIDEO_BUFFER_CHARS_NTSC 390
#define VIDEO_BUFFER_CHARS_PAL 480
#define VIDEO_LINES_NTSC 13
#define VIDEO_LINES_PAL 16
enum VIDEO_TYPES { AUTO = 0, PAL, NTSC };
extern uint16_t max_screen_size;
char screen[480];
char max7456_screen[VIDEO_BUFFER_CHARS_PAL];
void max7456_init(uint8_t system);

View File

@ -714,7 +714,7 @@ void osdInit(void)
rtc6705_soft_spi_set_channel(vtx_freq[current_vtx_channel]);
rtc6705_soft_spi_set_rf_power(masterConfig.vtx_power);
#endif
max7456_init(masterConfig.osdProfile.system);
max7456_init(masterConfig.osdProfile.video_system);
}

View File

@ -53,7 +53,8 @@ typedef enum {
typedef struct {
uint8_t system;
// AUTO / PAL / NTSC in VIDEO_TYPES enum
uint8_t video_system;
int16_t item_pos[OSD_MAX_ITEMS];
} osd_profile;

View File

@ -809,7 +809,7 @@ const clivalue_t valueTable[] = {
{ "vtx_power", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_power, .config.minmax = { 0, 1 } },
#endif
#ifdef OSD
{ "osd_system", VAR_UINT8 | MASTER_VALUE, &masterConfig.osdProfile.system, .config.minmax = { 0, 2 } },
{ "osd_video_system", VAR_UINT8 | MASTER_VALUE, &masterConfig.osdProfile.video_system, .config.minmax = { 0, 2 } },
{ "osd_main_voltage_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE], .config.minmax = { -480, 480 } },
{ "osd_rssi_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE], .config.minmax = { -480, 480 } },
{ "osd_timer_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_TIMER], .config.minmax = { -480, 480 } },

View File

@ -1524,7 +1524,7 @@ static bool processInCommand(void)
#endif
#ifdef OSD
case MSP_SET_OSD_CONFIG:
masterConfig.osdProfile.system = read8();
masterConfig.osdProfile.video_system = read8();
for (i = 0; i < OSD_MAX_ITEMS; i++)
masterConfig.osdProfile.item_pos[i] = read16();
break;