Skip to content

Commit

Permalink
Mon 18 Nov 2019 08:43:47 EST - quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
32teeth committed Nov 18, 2019
1 parent 8a5a90a commit 5595eb7
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Components/frodo-go/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
4 changes: 2 additions & 2 deletions Components/gogo/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
4 changes: 2 additions & 2 deletions Components/handy-go/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
4 changes: 2 additions & 2 deletions Components/stella-odroid-go/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
4 changes: 2 additions & 2 deletions Emulators/handy-go/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
Binary file removed Firmware/Releases/Retro ESP32.fw
Binary file not shown.
Binary file removed Firmware/Releases/odroid-go.zip
Binary file not shown.
Binary file modified Firmware/Releases/odroid-go/Retro ESP32.fw
Binary file not shown.
Binary file removed Firmware/Releases/retro-esp.zip
Binary file not shown.
Binary file modified Firmware/Releases/retro-esp/Retro ESP32.fw
Binary file not shown.
4 changes: 2 additions & 2 deletions Launchers/gogo/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static float adc_value = 0.0f;
static float forced_adc_value = 0.0f;
static bool battery_monitor_enabled = true;

#define BACKLIGHT_LEVEL_COUNT (4)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10, 33, 66, 100};
#define BACKLIGHT_LEVEL_COUNT (10)
static int BacklightLevels[BACKLIGHT_LEVEL_COUNT] = {10,20,30,40,50,60,70,80,90,100};
static int BacklightLevel = BACKLIGHT_LEVEL_COUNT - 1;

int is_backlight_initialized();
Expand Down
7 changes: 4 additions & 3 deletions Launchers/retro-esp32/components/odroid/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static void odroid_input_task(void *arg)
break;
}
}

/*
if (gamepad_state.values[ODROID_INPUT_START])
{
Expand All @@ -158,13 +158,13 @@ static void odroid_input_task(void *arg)
}

if (is_backlight_initialized())
{
const int DUTY_MAX = 0x1fff;
int duty = DUTY_MAX * (BacklightLevels[BacklightLevel] * 0.01f);
uint32_t currentDuty = ledc_get_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
if (currentDuty != duty)
{
changed = true;
Expand All @@ -176,13 +176,14 @@ static void odroid_input_task(void *arg)
ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty, 1);
ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_WAIT_DONE /*LEDC_FADE_NO_WAIT*/);
ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_WAIT_DONE);
//ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty);
changed = false;
}
}
*/

previous_gamepad_state = gamepad_state;

Expand Down
1 change: 1 addition & 0 deletions Launchers/retro-esp32/main/includes/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void draw_media(int x, int y, bool current);
void draw_folder(int x, int y, bool current);
void draw_battery();
void draw_speaker();
void draw_contrast();
void draw_numbers();
void draw_launcher();
void draw_launcher_options();
Expand Down
100 changes: 73 additions & 27 deletions Launchers/retro-esp32/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
int PREVIOUS = 0;
int32_t VOLUME = 0;
int32_t BRIGHTNESS = 0;
int32_t BRIGHTNESS_COUNT = 10;
int32_t BRIGHTNESS_LEVELS[10] = {10,20,30,40,50,60,70,80,90,100};
int8_t USER;
int8_t SETTING;
int8_t COLOR;
uint32_t currentDuty;

char** FILES;
char folder_path[256] = "";
Expand Down Expand Up @@ -111,11 +113,12 @@
VOLUME = odroid_settings_Volume_get();
odroid_settings_Volume_set(VOLUME);

BRIGHTNESS = get_brightness();
//odroid_settings_Backlight_set(BRIGHTNESS);

// Display
ili9341_init();
BRIGHTNESS = get_brightness();
apply_brightness();

// Joystick
odroid_input_gamepad_init();
Expand Down Expand Up @@ -152,7 +155,7 @@
RESTART = false;
break;
}
STEP = 0;
//STEP = 0;
RESTART ? restart() : SPLASH ? splash() : NULL;
draw_background();
restore_layout();
Expand All @@ -167,6 +170,7 @@
void debounce(int key) {
draw_battery();
draw_speaker();
draw_contrast();
while (gamepad.values[key]) odroid_input_gamepad_read(&gamepad);
}
//}#pragma endregion Debounce
Expand Down Expand Up @@ -301,6 +305,7 @@
for (int i = 0; i < 4; i++) draw_mask(0, i*h, w, h);
draw_battery();
draw_speaker();
draw_contrast();
}
//}#pragma endregion Mask

Expand Down Expand Up @@ -427,7 +432,6 @@

//{#pragma region Brightness
void draw_brightness() {
BRIGHTNESS = get_brightness();
int x = SCREEN.w - 120;
int y = POS.y + 106;
int w, h;
Expand All @@ -444,7 +448,7 @@
//if(BRIGHTNESS > 0) {
i = 0;
for(h = 0; h < 7; h++) {
for(w = 0; w < (10 * BRIGHTNESS)+10; w++) {
for(w = 0; w < (BRIGHTNESS_COUNT * BRIGHTNESS)+BRIGHTNESS+1; w++) {
if(SETTING == 3) {
buffer[i] = WHITE;
} else {
Expand All @@ -453,40 +457,41 @@
i++;
}
}
ili9341_write_frame_rectangleLE(x, y, (10 * BRIGHTNESS)+10, 7, buffer);
ili9341_write_frame_rectangleLE(x, y, (BRIGHTNESS_COUNT * BRIGHTNESS)+BRIGHTNESS+1, 7, buffer);
//}

//draw_speaker();
draw_contrast();
}
int32_t get_brightness() {
return odroid_settings_Backlight_get();
}
void set_brightness() {
odroid_settings_Backlight_set(BRIGHTNESS);
usleep(15000);
draw_brightness();
apply_brightness();
//draw_brightness();
}
void apply_brightness() {
const int DUTY_MAX = 0x1fff;
//BRIGHTNESS = get_brightness();
int duty = DUTY_MAX * (BRIGHTNESS_LEVELS[BRIGHTNESS] * 0.01f);

//if(is_backlight_initialized()) {
uint32_t currentDuty = ledc_get_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
printf("\n******\nBRIGHTNESS:%d\nBRIGHTNESS_LEVELS[%d]:%d\nduty:%d\ncurrentDuty:%d\n******\n",
BRIGHTNESS,
BRIGHTNESS,
BRIGHTNESS_LEVELS[BRIGHTNESS],
duty,
currentDuty);
//if (currentDuty != duty) {
ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty, 1);
ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_WAIT_DONE);
ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty);
//}
//}

//backlight_percentage_set(BRIGHTNESS_LEVELS[BRIGHTNESS]);
if(is_backlight_initialized()) {
currentDuty = ledc_get_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
if (currentDuty != duty) {
//ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, currentDuty);
//ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
//ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty, 1000);
//ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_WAIT_DONE /*LEDC_FADE_NO_WAIT|LEDC_FADE_WAIT_DONE|LEDC_FADE_MAX*/);
//ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty);
//ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
ledc_set_fade_time_and_start(
LEDC_LOW_SPEED_MODE,
LEDC_CHANNEL_0,
duty,
25,
LEDC_FADE_WAIT_DONE
);
}
}
}
//}#pragma endregion Brightness

Expand Down Expand Up @@ -695,6 +700,46 @@
ili9341_write_frame_rectangleLE(x, y, w, h, buffer);
}

void draw_contrast() {
int32_t dy = 0;
switch(BRIGHTNESS) {
case 10:
case 9:
case 8:
dy = 0;
break;
case 7:
case 6:
case 5:
dy = 16;
break;
case 4:
case 3:
case 2:
dy = 32;
break;
case 1:
case 0:
dy = 48;
break;
}
int i = 0;
int x = SCREEN.w - 72;
int y = 8;
int h = 16;
int w = 16;

draw_mask(x,y,16,16);

for(h = 0; h < 16; h++) {
for(w = 0; w < 16; w++) {
buffer[i] = brightness[dy+h][w] == WHITE ? WHITE : GUI.bg;
i++;
}
}
ili9341_write_frame_rectangleLE(x, y, w, h, buffer);
}

void draw_numbers() {
int x = 296;
int y = POS.y + 48;
Expand Down Expand Up @@ -830,6 +875,7 @@
//}#pragma endregion Sort

void get_files() {
free(FILES);
FILES = (char**)malloc(MAX_FILES * sizeof(void*));
ROMS.total = 0;

Expand Down Expand Up @@ -1181,12 +1227,12 @@
static void launcher() {
draw_battery();
draw_speaker();
draw_contrast();
while (true) {
/*
Get Gamepad State
*/
odroid_input_gamepad_read(&gamepad);

/*
LEFT
*/
Expand Down Expand Up @@ -1243,7 +1289,7 @@
}
}
if(SETTING == 3) {
if(BRIGHTNESS < 9) {
if(BRIGHTNESS < (BRIGHTNESS_COUNT-1)) {
BRIGHTNESS++;
set_brightness();
usleep(200000);
Expand Down
Loading

0 comments on commit 5595eb7

Please sign in to comment.