aboutsummaryrefslogtreecommitdiffstats
path: root/hal/api.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hal/api.cpp')
-rw-r--r--hal/api.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/hal/api.cpp b/hal/api.cpp
index 961cdd5..5666763 100644
--- a/hal/api.cpp
+++ b/hal/api.cpp
@@ -13,14 +13,14 @@ extern "C" {
#include "../init.hpp"
#include "../globals.hpp"
-void Api::init() {
+void AppAPI::init() {
if (!m_init_done) {
init_display();
m_init_done = 1;
}
}
-void Api::init_display() {
+void AppAPI::init_display() {
sleep_ms(500); // Wait for the OLED to settle
oledInit(&m_oled, OLED_128x64, 0x3d, 0, 0, 1, SDA_PIN, SCL_PIN, RESET_PIN, 1000000L);
oledFill(&m_oled, 0,1);
@@ -29,44 +29,44 @@ void Api::init_display() {
//oledSetTextWrap(&oled, true);
}
-void Api::display_power(bool mode) {
+void AppAPI::display_power(bool mode) {
oledPower(&m_oled, mode);
}
-void Api::display_set_contrast(unsigned char contrast) {
+void AppAPI::display_set_contrast(unsigned char contrast) {
oledSetContrast(&m_oled, contrast);
}
-int Api::display_write_string(int iScrollX, int x, int y, const char *szMsg, int iSize, int bInvert, int bRender) {
+int AppAPI::display_write_string(int iScrollX, int x, int y, const char *szMsg, int iSize, int bInvert, int bRender) {
oledWriteString(&m_oled, iScrollX, x, y, szMsg, iSize, bInvert, 0);
m_writebb_needed = true;
return 0;
}
-void Api::display_fill(unsigned char ucData, int bRender) {
+void AppAPI::display_fill(unsigned char ucData, int bRender) {
oledFill(&m_oled, ucData, bRender);
}
-void Api::display_draw_line(int x1, int y1, int x2, int y2, int bRender) {
+void AppAPI::display_draw_line(int x1, int y1, int x2, int y2, int bRender) {
oledDrawLine(&m_oled, x1, y1, x2, y2, 0);
m_writebb_needed = true;
}
-void Api::display_draw_rectange(int x1, int y1, int x2, int y2, uint8_t ucColor, uint8_t bFilled) { // FIXME: Fix typo
+void AppAPI::display_draw_rectange(int x1, int y1, int x2, int y2, uint8_t ucColor, uint8_t bFilled) { // FIXME: Fix typo
oledRectangle(&m_oled, x1, y1, x2, y2, ucColor, bFilled);
m_writebb_needed = true; // Write the back buffer, after experimentation, seems to be required when drawing this shape
}
-void Api::display_draw_ellipse(int iCenterX, int iCenterY, int32_t iRadiusX, int32_t iRadiusY, uint8_t ucColor, uint8_t bFilled) {
+void AppAPI::display_draw_ellipse(int iCenterX, int iCenterY, int32_t iRadiusX, int32_t iRadiusY, uint8_t ucColor, uint8_t bFilled) {
oledEllipse(&m_oled, iCenterX, iCenterY, iRadiusX, iRadiusY, ucColor, bFilled);
m_writebb_needed = true;
}
-void Api::display_write_buffer(uint8_t *pBuffer) {
+void AppAPI::display_write_buffer(uint8_t *pBuffer) {
oledDumpBuffer(&m_oled, pBuffer);
}
-bool Api::display_write_backbuffer() {
+bool AppAPI::display_write_backbuffer() {
#ifndef SDL2_BUILD
if (m_writebb_needed)
oledDumpBuffer(&m_oled, m_ucBuffer);
@@ -78,11 +78,11 @@ bool Api::display_write_backbuffer() {
#endif
}
-int Api::display_write_pixel(int x, int y, unsigned char ucColor, int bRender) {
+int AppAPI::display_write_pixel(int x, int y, unsigned char ucColor, int bRender) {
return oledSetPixel(&m_oled, x, y, ucColor, bRender);
}
-void Api::gui_popup_generic(std::string &title, std::string &body, int max_title_length, int max_body_length) {
+void AppAPI::gui_popup_generic(std::string &title, std::string &body, int max_title_length, int max_body_length) {
oledRectangle(&m_oled, 9,7, 119,63, 0, 1); // Background
oledRectangle(&m_oled, 9,7, 119,63, 1, 0); // Popup border
oledRectangle(&m_oled, 9,7, 119,16, 1, 1); // Title background, FIXME pixel bleeding
@@ -112,7 +112,7 @@ void Api::gui_popup_generic(std::string &title, std::string &body, int max_title
oledWriteString(&m_oled, 0, 13,2, body.c_str(), FONT_8x8, 0, 1); // Draw body
}
-bool Api::gui_popup_text(std::string title, std::string body){
+bool AppAPI::gui_popup_text(std::string title, std::string body){
m_button_last_pressed = BUTTON_NONE;
m_interpret_button_press = false;
@@ -126,7 +126,7 @@ bool Api::gui_popup_text(std::string title, std::string body){
return true;
}
-bool Api::gui_popup_booleanchoice(std::string title, std::string body){
+bool AppAPI::gui_popup_booleanchoice(std::string title, std::string body){
m_button_last_pressed = BUTTON_NONE;
m_interpret_button_press = false;
@@ -153,7 +153,7 @@ bool Api::gui_popup_booleanchoice(std::string title, std::string body){
return choice;
}
-void Api::gui_popup_intchoice_footer(int current_num, int min_num, int max_num) {
+void AppAPI::gui_popup_intchoice_footer(int current_num, int min_num, int max_num) {
char buf[30];
snprintf(&buf[0], sizeof(buf),
"Select: %d (%d/%d)",
@@ -165,7 +165,7 @@ void Api::gui_popup_intchoice_footer(int current_num, int min_num, int max_num)
m_writebb_needed = true; display_write_backbuffer();
}
-int Api::gui_popup_intchoice(std::string title, std::string body, int min_num, int max_num, int default_num, int step){
+int AppAPI::gui_popup_intchoice(std::string title, std::string body, int min_num, int max_num, int default_num, int step){
m_button_last_pressed = BUTTON_NONE;
m_interpret_button_press = false;
@@ -203,7 +203,7 @@ int Api::gui_popup_intchoice(std::string title, std::string body, int min_num, i
return current_num;
}
-void Api::gui_popup_strchoice_footer(const char selection[]) {
+void AppAPI::gui_popup_strchoice_footer(const char selection[]) {
std::string buf{selection};
buf.insert(0, "Select: ");
@@ -238,7 +238,7 @@ void Api::gui_popup_strchoice_footer(const char selection[]) {
m_writebb_needed = true; display_write_backbuffer();
}
-int Api::gui_popup_strchoice(std::string title, std::string body, const char *choices[27], int choices_size, int min_index, int max_index, int default_index){
+int AppAPI::gui_popup_strchoice(std::string title, std::string body, const char *choices[27], int choices_size, int min_index, int max_index, int default_index){
m_button_last_pressed = BUTTON_NONE;
m_interpret_button_press = false;
if (max_index == -1)
@@ -278,7 +278,7 @@ int Api::gui_popup_strchoice(std::string title, std::string body, const char *ch
return current_index;
}
-bool Api::gui_footer_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) {
+bool AppAPI::gui_footer_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) {
// Max chars per line for FONT_8x8 is 16 chars
// Max chars per line for FONT_6x8 is 21 chars
// Truncate longer text
@@ -299,7 +299,7 @@ bool Api::gui_footer_text(std::string text, int offset_x, int offset_row, bool i
return oledWriteString(&m_oled, 0,offset_x,7-offset_row, text.c_str(), font, invert, 0);
}
-bool Api::gui_header_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) {
+bool AppAPI::gui_header_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) {
// Max chars per line for FONT_8x8 is 16 chars
// Max chars per line for FONT_6x8 is 21 chars
// Truncate longer text
@@ -320,11 +320,11 @@ bool Api::gui_header_text(std::string text, int offset_x, int offset_row, bool i
return oledWriteString(&m_oled, 0,offset_x,0+offset_row, text.c_str(), font, invert, 0);
}
-bool Api::performance_set(int perf) {
+bool AppAPI::performance_set(int perf) {
return false;
}
-bool Api::datetime_get(datetime_t *t) {
+bool AppAPI::datetime_get(datetime_t *t) {
#ifndef SDL2_BUILD
return rtc_get_datetime(t);
#else
@@ -332,7 +332,7 @@ bool Api::datetime_get(datetime_t *t) {
#endif
}
-bool Api::datetime_set(datetime_t *t) {
+bool AppAPI::datetime_set(datetime_t *t) {
#ifndef SDL2_BUILD
return rtc_set_datetime(t);
#else
@@ -340,10 +340,10 @@ bool Api::datetime_set(datetime_t *t) {
#endif
}
-uint Api::button_last_get() {
+uint AppAPI::button_last_get() {
return m_button_last_pressed;
}
-void Api::button_last_set(uint gpio) {
+void AppAPI::button_last_set(uint gpio) {
m_button_last_pressed = gpio;
}