Skip to content

Commit

Permalink
fix: clear screen on 128x32 displays
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosHall committed Sep 9, 2024
1 parent cc95dcd commit da1ae3c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion firmware/components/minino_config/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ menu "OLED Screen Configuration"

endmenu

menu "KEYBOARD Configuration"
menu "Keyboard Configuration"

config GPIO_RANGE_MAX
int
Expand Down
12 changes: 6 additions & 6 deletions firmware/main/drivers/oled_driver/oled_driver_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include "oled_driver.h"

#define tag "oled_driver_i2c"

#if CONFIG_I2C_PORT_0
#define I2C_NUM I2C_NUM_0
#elif CONFIG_I2C_PORT_1
Expand All @@ -21,6 +19,8 @@
#define I2C_MASTER_FREQ_HZ \
400000 /*!< I2C clock of SH1106 can run at 400 kHz max. */

static const char* TAG = "oled_driver_i2c";

void i2c_master_init(oled_driver_t* dev,
int16_t sda,
int16_t scl,
Expand Down Expand Up @@ -105,9 +105,9 @@ void i2c_init(oled_driver_t* dev, int width, int height) {

esp_err_t espRc = i2c_master_cmd_begin(I2C_NUM, cmd, 10 / portTICK_PERIOD_MS);
if (espRc == ESP_OK) {
ESP_LOGI(tag, "OLED configured successfully");
ESP_LOGI(TAG, "OLED configured successfully");
} else {
ESP_LOGE(tag, "OLED configuration failed. code: 0x%.2X", espRc);
ESP_LOGE(TAG, "OLED configuration failed. code: 0x%.2X", espRc);
}
i2c_cmd_link_delete(cmd);
}
Expand Down Expand Up @@ -260,9 +260,9 @@ void i2c_hardware_scroll(oled_driver_t* dev, oled_driver_scroll_type_t scroll) {
i2c_master_stop(cmd);
espRc = i2c_master_cmd_begin(I2C_NUM, cmd, 10 / portTICK_PERIOD_MS);
if (espRc == ESP_OK) {
ESP_LOGD(tag, "Scroll command succeeded");
ESP_LOGD(TAG, "Scroll command succeeded");
} else {
ESP_LOGE(tag, "Scroll command failed. code: 0x%.2X", espRc);
ESP_LOGE(TAG, "Scroll command failed. code: 0x%.2X", espRc);
}

i2c_cmd_link_delete(cmd);
Expand Down
8 changes: 4 additions & 4 deletions firmware/main/modules/gps/wardriving/wardriving_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

#define MAC_ADDRESS_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x"
#define EMPTY_MAC_ADDRESS "00:00:00:00:00:00"
#define MAX_CSV_LINES 200
#define CSV_LINE_SIZE 150 // Got it from real time tests
#define CSV_FILE_SIZE CSV_LINE_SIZE* MAX_CSV_LINES
#define CSV_FILE_SIZE (CSV_LINE_SIZE) * (MAX_CSV_LINES)
#define CSV_HEADER_LINES 2 // Check `csv_header` variable
#define MAX_CSV_LINES 200 + CSV_HEADER_LINES

#define WIFI_SCAN_REFRESH_RATE_MS 3000
#define DISPLAY_REFRESH_RATE_SEC 2
Expand Down Expand Up @@ -175,7 +175,7 @@ void wardriving_module_save_to_file(gps_t* gps) {
ESP_LOGI(TAG, "Free heap size before allocation: %" PRIu32 " bytes",
esp_get_free_heap_size());
ESP_LOGI(TAG, "Allocating %d bytes for csv_file_buffer", CSV_FILE_SIZE);
csv_file_buffer = malloc(CSV_FILE_SIZE); // Here does not work
csv_file_buffer = malloc(CSV_FILE_SIZE);
if (csv_file_buffer == NULL) {
ESP_LOGE(TAG, "Failed to allocate memory for csv_file_buffer");
return;
Expand Down Expand Up @@ -297,7 +297,7 @@ void wardriving_module_begin() {
ESP_LOGI(TAG, "Free heap size before allocation: %" PRIu32 " bytes",
esp_get_free_heap_size());
ESP_LOGI(TAG, "Allocating %d bytes for csv_file_buffer", CSV_FILE_SIZE);
csv_file_buffer = malloc(CSV_FILE_SIZE); // Here works
csv_file_buffer = malloc(CSV_FILE_SIZE);
if (csv_file_buffer == NULL) {
ESP_LOGE(TAG, "Failed to allocate memory for csv_file_buffer");
return;
Expand Down
2 changes: 1 addition & 1 deletion firmware/main/modules/menus_module/menus_screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ void menus_screens_display_menus_f(menus_manager_t* ctx) {

#ifdef CONFIG_RESOLUTION_128X64
oled_screen_display_selected_item_box();
oled_screen_display_show();
#endif
oled_screen_display_show();
}
11 changes: 9 additions & 2 deletions firmware/main/modules/screen_saver/screen_saver.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "screen_saver.h"

#include "bitmaps_general.h"
#include "esp_log.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Expand All @@ -9,6 +10,7 @@
#include "preferences.h"

static int IDLE_TIMEOUT_S = 30;
static const char* TAG = "screen_saver";

static volatile bool screen_saver_running;
esp_timer_handle_t screen_savar_idle_timer2;
Expand Down Expand Up @@ -38,13 +40,18 @@ static void show_splash_screen() {
screen_saver_running = true;
int w_screen_space = SCREEN_WIDTH2 - logo.width;
int h_screen_space = SCREEN_HEIGHT2 - logo.height;
h_screen_space = h_screen_space == 0 ? 2 : h_screen_space;
int start_x_position = w_screen_space / 2;
#if CONFIG_RESOLUTION_128X64
static int start_y_position = 16;
static int x_direction = 1;
static int y_direction = 1;
#else
static int start_y_position = 0;
static int y_direction = 0;
#endif
static int x_direction = 1;

while (screen_saver_running) {
// oled_screen_clear_buffer();
oled_screen_display_bitmap(logo.bitmap, start_x_position, start_y_position,
logo.width, logo.height, OLED_DISPLAY_NORMAL);

Expand Down

0 comments on commit da1ae3c

Please sign in to comment.