Skip to content

Commit

Permalink
feature:optimize display. To avoid OLED/LCD display burn-in
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVon2021 committed Nov 7, 2024
1 parent bcc37a7 commit dd02993
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 184 deletions.
11 changes: 1 addition & 10 deletions script/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"version": "v1.5.0",
"md5value": "",
"oled":{
"oled_always_enable": 1,
"restart_show_time": 30,
"interval_display_time": 5
},
"atx":{
"power_on_delay":500,
"power_off_delay":5000
}
"md5value": ""
}
6 changes: 2 additions & 4 deletions src/common/blikvm_util/blikvm_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,8 @@ blikvm_int32_t skdy_get_int_uptime()
char buffer[256];
fp = fopen("/proc/uptime", "r");
fgets(buffer, 256, fp);
double uptime_seconds = atof(buffer);
blikvm_int32_t uptime_minutes = uptime_seconds / 60;
fclose(fp);
return uptime_minutes;
blikvm_int32_t uptime_seconds = (blikvm_int32_t)atof(buffer);
return uptime_seconds;
}

int getWifiSignalStrength(const char* interface, int* signalStrength) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/blikvm_util/blikvm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ blikvm_int8_t isWifiCardAvailable();

/**
* @brief : get os's up time
* @return: the os's up since the Epoch, unit:min
* @return: the os's up since the Epoch, unit:sec
*/
blikvm_int32_t skdy_get_int_uptime();

Expand Down
67 changes: 25 additions & 42 deletions src/config/blikvm_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,6 @@ blikvm_config_t* blikvm_read_config(blikvm_int8_t* file_path)
break;
}

// const cJSON *switch_handle = NULL;
// switch_handle = cJSON_GetObjectItemCaseSensitive(root, "switch_handle");
// if (cJSON_IsObject(switch_handle))
// {
// const cJSON *switch_enable = cJSON_GetObjectItemCaseSensitive(switch_handle, "switch_enable");
// const cJSON *switch_path = cJSON_GetObjectItemCaseSensitive(switch_handle, "switch_path");

// if (!cJSON_IsNumber(switch_enable))
// {
// BLILOG_E(TAG, "switch function is disable\n");
// }
// else
// {
// g_config.switch_handle.enable = switch_enable->valueint;
// BLILOG_D(TAG, "switch function is enable\n");
// }

// if (!cJSON_IsString(switch_path))
// {
// BLILOG_E(TAG, "switch path is not string\n");
// }
// else
// {
// memcpy(g_config.switch_handle.device_path, switch_path->valuestring, strlen(switch_path->valuestring));
// BLILOG_D(TAG, "switch device:%s\n",switch_path->valuestring);
// }
// }

const cJSON *atx = NULL;
atx = cJSON_GetObjectItemCaseSensitive(root, "atx");
if (cJSON_IsObject(atx))
Expand Down Expand Up @@ -135,29 +107,40 @@ blikvm_config_t* blikvm_read_config(blikvm_int8_t* file_path)
}
}

const cJSON *oled = cJSON_GetObjectItemCaseSensitive(root, "oled");
const cJSON *oled = cJSON_GetObjectItemCaseSensitive(root, "display");
if (cJSON_IsObject(oled))
{
const cJSON *oled_enable = cJSON_GetObjectItemCaseSensitive(oled, "oled_always_enable");
const cJSON *restart_show_time = cJSON_GetObjectItemCaseSensitive(oled, "restart_show_time");
const cJSON *interval_display_time = cJSON_GetObjectItemCaseSensitive(oled, "interval_display_time");

if (cJSON_IsNumber(oled_enable))
const cJSON *isActive = cJSON_GetObjectItemCaseSensitive(oled, "isActive");
const cJSON *mode = cJSON_GetObjectItemCaseSensitive(oled, "mode");
const cJSON *onBootTime = cJSON_GetObjectItemCaseSensitive(oled, "onBootTime");
const cJSON *cycleInterval = cJSON_GetObjectItemCaseSensitive(oled, "cycleInterval");
const cJSON *displayTime = cJSON_GetObjectItemCaseSensitive(oled, "displayTime");

if (cJSON_IsBool(isActive)) {
g_config.oled.isActive = cJSON_IsTrue(isActive) ? 1 : 0;
BLILOG_I(TAG, "display isActive: %d\n", g_config.oled.isActive);
}
if (cJSON_IsNumber(mode))
{
BLILOG_I(TAG, "oled_always_enable: %d\n", oled_enable->valueint);
g_config.oled.oled_always_enable = oled_enable->valueint;
BLILOG_I(TAG, "display mode: %d\n", mode->valueint);
g_config.oled.mode = mode->valueint;
}

if (cJSON_IsNumber(restart_show_time))
if (cJSON_IsNumber(onBootTime))
{
BLILOG_I(TAG,"restart_show_time: %d\n", restart_show_time->valueint);
g_config.oled.restart_show_time = restart_show_time->valueint;
BLILOG_I(TAG,"onBootTime: %d\n", onBootTime->valueint);
g_config.oled.onBootTime = onBootTime->valueint;
}

if (cJSON_IsNumber(interval_display_time))
if (cJSON_IsNumber(cycleInterval))
{
BLILOG_I(TAG,"cycleInterval: %d\n", cycleInterval->valueint);
g_config.oled.cycleInterval = cycleInterval->valueint;
}
if (cJSON_IsNumber(displayTime))
{
BLILOG_I(TAG,"interval_display_time: %d\n", interval_display_time->valueint);
g_config.oled.interval_display_time = interval_display_time->valueint;
BLILOG_I(TAG,"displayTime: %d\n", displayTime->valueint);
g_config.oled.displayTime = displayTime->valueint;
}
}
else
Expand Down
3 changes: 2 additions & 1 deletion src/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#define TAG "MAIN"


static char* config_json_path= (char*)"/usr/bin/blikvm/package.json";
//static char* config_json_path= (char*)"/mnt/blikvm/web_src/web_server/config/app.json";
static char* config_json_path= (char*)"/mnt/exec/release/config/app.json";
static blikvm_log_t g_log_config={0};
static blikvm_config_t* g_config = NULL;

Expand Down
31 changes: 8 additions & 23 deletions src/kvmd/blikvm_gpio/blikvm_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ blikvm_int8_t blikvm_gpio_init()
szBoardName = AIOGetBoardName();

#ifdef VER4
AIOAddGPIO(SW2, GPIO_IN);
AIOAddGPIO(SW1, GPIO_IN);
AIOAddGPIO(SW2_LED, GPIO_OUT);
#endif
g_gpio.init = 1;
Expand Down Expand Up @@ -101,39 +101,24 @@ blikvm_int8_t blikvm_gpio_start()
static blikvm_void_t *blikvm_gpio_loop(void *_)
{
#ifdef VER4
static blikvm_gpio_state_t sw1 = {0};
static blikvm_gpio_state_t sw2 = {0};
#endif
while (1)
{
#ifdef VER4
if(AIOReadGPIO(SW2) == 1)
if(AIOReadGPIO(SW1) == 1)
{
sw2.count = (sw2.count + 1) % 6;
sw1.count = (sw1.count + 1) % 6;
}
else
{
sw2.count = 0;
sw2.triggered = 0;
sw1.count = 0;
}
if( sw2.count >= 5)
if( sw1.count >= 5)
{
// if oled is open, change it to close; if oled is close, change it to open;
if((sw2.state == 1) && !sw2.triggered )
{
BLILOG_D(TAG,"open oled\n");
blikvm_backlight_open();
blikvm_oled_set_display_enable(0);
sw2.state = 0;
sw2.triggered = 1;
}
else if((sw2.state == 0) && !sw2.triggered )
{
BLILOG_D(TAG,"close oled\n");
blikvm_backlight_close();
blikvm_oled_set_display_enable(1);
sw2.state = 1;
sw2.triggered = 1;
}
blikvm_oled_open_one_cycle();
sw1.count = 0;
}
if(sw2.act_cycle == 0 )
{
Expand Down
Loading

0 comments on commit dd02993

Please sign in to comment.