Repository navigation
Docs for devs
Tip: use table of contents at the right to skip to sections Disclaimer: If the headline is italic the section is AI generated
- Create new class that inherits from Window
1.1. Create the methods update_window() that returns Bitarray2D
1.2. Create method handle_key_down(KeyPress keypress)
- Add a new MenuOption to MainMenuWindow.cpp and change size of options vector
- Implement all the functions you need
- To get screen size you can do
#include "constant/Constants.h"and then use SCREEN_HEIGHT and SCREEN_WIDTH - To get time since boot do
#include "utils/Utils.h"and then useUtils::us_since_boot() - To check for a key press use
keypress.key_calculator == Chars::KEY_MAP.at("1")(you can also usekeypress.key_raworkeypress.key_keyboard) - To check if alpha or shift is activated use
keypress.alphaorkeypress.shift
You can create a Bitset2D with the following methods:
-
Bitset2D()for dynamic size and a starting size of 0, 0 -
Bitset2D(uint32_t width, uint32_t height, bool value)to initialize with a specific size and a default value -
Bitset2D(uint32_t width, const DynamicBitset& other)to initialize with a width. The height and values are copied from the dynamic bit set -
Bitset2D(uint32_t width, uint32_t height, const std::vector<std::vector<uint8_t>>& plane)same as above but height also specific -
Bitset2D(const Bitset2D& other)copies the bit set passed in (height, width, values)
Methods:
-
.at(uint32_t index)to get the value at an index in the dynamic bit set -
.width()to get the width of the bit set -
.height()to get the height of the bit set -
.get_bit(uint32_t coord_x, uint32_t coord_y)to get the bit at a specific x and y coordinate -
.copy(uint32_t x_start, uint32_t y_start, uint32_t width, uint32_t height, Bitset2D& destination)copies a section of a bit set into another -
.put_chars(uint32_t coord_x, uint32_t coord_y, const std::map<KEY, Bitset2D>& font, KEY_SET text, bool resize_if_needed)to but a character on a specific coordinate with the option to extend the bit set if needed -
.set(uint32_t coord_x, uint32_t coord_y, const Bitset2D& other, bool resize_if_needed)inserts a bit set into another at a coordinate with the option to extend the bit set if needed -
.set_column(uint32_t coord_x, const DynamicBitset& other)replaces a column in the bit set with a dynamic bit set -
.set_bit(uint32_t coord_x, uint32_t coord_y, bool value)to set a value of one pixel at a coordinate -
.erase_x(uint32_t coord_x)to remove a column at a specific x coordinate -
.erase_y(uint32_t coord_y)to remove a row at a specific y coordinate -
.pop_back_x()to remove the last column in the bit set -
.clear()to clear the bit set -
.push_back(const DynamicBitset& other)to add a dynamic bit set to the end of the bit set -
.push_front(const DynamicBitset& other)to add a dynamic bit set to the beginning of the bit set -
.extend_right(const Bitset2D& other)to extend the bit set to the right with another bit set -
.extend_right(uint32_t length, bool value)to extend the bit set to the right with a specific length and value -
.extend_down(const Bitset2D& other)to extend the bit set downwards with another bit set -
.extend_down(uint32_t length, bool value)to extend the bit set downwards with a specific length and value -
.extend_left(const Bitset2D& other)to extend the bit set to the left with another bit set -
.extend_left(uint32_t length, bool value)to extend the bit set to the left with a specific length and value -
.extend_up(const Bitset2D& other)to extend the bit set upwards with another bit set -
.extend_up(uint32_t length, bool value)to extend the bit set upwards with a specific length and value -
.to_string()to convert the bit set to a string -
.to_string_formatted()to convert the bit set to a formatted string
Behavior with operators:
-
Bitset2D::operator[](uint32_t index)to get the dynamic bit set at an index in the 2D bit set -
Bitset2D::operator==(const Bitset2D& other)to check if two 2D bit sets are equal -
Bitset2D::operator!=(const Bitset2D& other)to check if two 2D bit sets are not equal -
Bitset2D::operator=(const Bitset2D& other)to assign one 2D bit set to another -
Bitset2D::operator+(const Bitset2D& other)to concatenate two 2D bit sets
You can create a DynamicBitset with the following methods:
-
DynamicBitset()for dynamic size and a starting size of 0 -
DynamicBitset(uint32_t count, bool value)to initialize with a specific size and a default value -
DynamicBitset(uint32_t count, std::vector<uint8_t> values)to initialize with a specific size and values from a vector of bytes -
DynamicBitset(uint32_t count, std::vector<bool> values)to initialize with a specific size and values from a vector of booleans -
DynamicBitset(const DynamicBitset& other)copies the bit set passed in (size, values)
Methods:
-
.at(uint32_t index)to get the value at an index in the dynamic bit set -
.size()to get the size of the bit set -
.get_bytes()to get the bytes of the bit set -
.copy(uint32_t start, uint32_t width)copies a section of a bit set -
.set(uint32_t index, bool value)to set a value of one bit at an index -
.set(uint32_t index, const DynamicBitset& other)inserts a bit set into another at an index -
.insert(uint32_t index, bool bit)to insert a bit at a specific index -
.insert(uint32_t index, const DynamicBitset& bits)to insert a bit set at a specific index -
.erase(uint32_t index)to remove a bit at a specific index -
.clear()to clear the bit set -
.push_back(bool bit)to add a bit to the end of the bit set -
.push_front(bool bit)to add a bit to the beginning of the bit set -
.pop_back()to remove the last bit in the bit set -
.pop_front()to remove the first bit in the bit set -
.extend(const DynamicBitset& other)to extend the bit set with another bit set -
.extend(uint32_t length, bool value)to extend the bit set with a specific length and value -
.extend_left(const DynamicBitset& other)to extend the bit set to the left with another bit set -
.extend_left(uint32_t length, bool value)to extend the bit set to the left with a specific length and value -
.to_string()to convert the bit set to a string -
.to_string_formatted(uint32_t bytes_per_line)to convert the bit set to a formatted string
Behavior with operators:
-
DynamicBitset::operator[](uint32_t i)to get the bit at an index in the dynamic bit set -
DynamicBitset::operator==(const DynamicBitset& other)to check if two dynamic bit sets are equal -
DynamicBitset::operator!=(const DynamicBitset& other)to check if two dynamic bit sets are not equal -
DynamicBitset::operator=(const DynamicBitset& other)to assign one dynamic bit set to another -
DynamicBitset::operator+(const DynamicBitset& other)to concatenate two dynamic bit sets
The Window class is used to manage the window of the application. It provides methods to update the window, get the render canvas, add graphics to the window, clear the window, clear symbols, change symbols, scroll left and right, and handle key down and up events.
You can create a Window with the following methods:
-
Window()to initialize the window
Methods:
-
.update_window()to update the window and return the render canvas -
.get_render_canvas()to get the render canvas of the window -
.add_to_window(const Bitset2D& graphic, int corner_x, int corner_y)to add a graphic to the window at a specific corner -
.clear_window()to clear the window -
.clear_symbols()to clear the symbols -
.change_symbol(std::string symbol, bool state)to change the state of a symbol -
.scroll_left()to scroll the window to the left -
.scroll_right()to scroll the window to the right -
.handle_key_down(KeyPress keypress)to handle the key down event -
.handle_key_up(KeyPress keypress)to handle the key up event -
.got_focus()to handle the event when the window got focus -
.lost_focus()to handle the event when the window lost focus
The Decimal class is used to represent decimal numbers with a high precision. It provides methods for creating decimals, comparing them, and performing arithmetic operations.
You can create a Decimal with the following methods:
-
Decimal()to initialize the decimal with a value of 0 -
Decimal(double value)to initialize the decimal with a specific double value -
Decimal(int64_t value, int16_t exp)to initialize the decimal with a specific integer value and exponent
Methods:
-
.sign()to get the sign of the decimal (returns 1 for positive, -1 for negative, and 0 for zero) -
.normalize()to normalize the decimal (removes trailing zeros and adjusts the exponent) -
.shift_comma(int8_t shift)to shift the decimal point by a specific amount -
.change_accuracy(int8_t shift)to change the accuracy of the decimal by shifting the decimal point
Behavior with operators:
-
Decimal::operator==(const Decimal& other)to check if two decimals are equal -
Decimal::operator!=(const Decimal& other)to check if two decimals are not equal -
Decimal::operator<(const Decimal& other)to check if one decimal is less than another -
Decimal::operator>(const Decimal& other)to check if one decimal is greater than another -
Decimal::operator<=(const Decimal& other)to check if one decimal is less than or equal to another -
Decimal::operator>=(const Decimal& other)to check if one decimal is greater than or equal to another -
Decimal::operator-()to negate the decimal -
Decimal::operator=(const Decimal& other)to assign one decimal to another -
Decimal::operator+(const Decimal& other)to add two decimals
You can create a Graphics with:
Graphics()
Methods:
-
Graphics::create_text(const std::string& text, FONT& table, const uint16_t spacing)to create a Bitset2D text from string -
Graphics::create_text(const KEY_SET text, FONT& table, const uint16_t spacing)to create a Bitset2D text from a set of keys
Constants:
-
Graphics::EMPTY_SCREENto represent an empty screen -
Graphics::LOGO_SCREENto represent a logo screen -
Graphics::SCREEN_SYMBOLSto represent screen symbols
Fonts:
-
Graphics::SYMBOLS_9_HIGHto represent symbols with a height of 9 -
Graphics::SYMBOLS_7_HIGHto represent symbols with a height of 7 -
Graphics::SYMBOLS_6_HIGHto represent symbols with a height of 6
The Utils class provides utility functions that are used throughout the application. It provides methods for sleeping, getting the time since boot, setting the time start point, and getting the total and free heap.
Methods:
-
Utils::sleep_for_ms(int milliseconds)to sleep for a specific number of milliseconds -
Utils::us_since_boot()to get the time in microseconds since the system boot -
Utils::set_time_start_point()to set the start point for the time measurement -
Utils::get_total_heap()to get the total heap size -
Utils::get_free_heap()to get the free heap size
Methods:
-
throw_error(ErrorType err)throws a error -
error_thrown()returns if a error waas thrown -
get_error()returns the current error -
render_error()returns a Bitset2D that displays the current error -
error_handled()unthrows the error (sets error to FINE)
Constants:
-
KEY_MAPa map from string to keycode -
KEY_MAP_SHIFTa map from string to keycode if shift is on -
KEY_MAP_ALPHAa map form string to keycode if alpha is on
Methods:
-
in_key_set(KEY value, const KEY_SET& vector)checks if a KEY is in a KEY_SET
-
SCREEN_WIDTHthe width of the screen (96) -
SCREEN_HEIGHTthe height of the screen (31) -
OS_VERSIONthe version of the CasioOS running
Types of errors:
MATH_ERRORPUFFER_ERRORSYNTAX_ERRORARGUMENT_ERRORSTORAGE_ERRORTIME_ERROR-
FINE(this is the state of "error" that indicates that there is no error)
LCDConstants defines a set of constants that are used for LCD control. These constants represent various commands, modes, addresses, and statuses related to the LCD.
Constants:
-
SET_MODEto set the mode of the LCD -
SET_START_BANKto set the start bank of the LCD -
DEVICE_SELECTto select the device -
RAM_ACCESSto access the RAM -
LOAD_X_ADDRESSto load the X address -
C_LAST_COMMANDto represent the last command -
C_COMMAND_FOLLOWINGto represent the command following -
T_ROW_MODEto set the row mode -
T_MIXED_MODEto set the mixed mode -
E_BLANK_STATUSto represent the blank status -
E_NORMAL_STATUSto represent the normal status -
E_ALL_ON_STATUSto represent the all on status -
E_INVERSE_STATUSto represent the inverse status -
M_1_32_MULTIPLEXto set the multiplex -
B_SET_START_BANK_0to set the start bank 0 -
B_SET_START_BANK_1to set the start bank 1 -
B_SET_START_BANK_2to set the start bank 2 -
B_SET_START_BANK_3to set the start bank 3 -
G_RAM_CHARACTER_MODEto set the character mode in RAM -
G_RAM_HALF_GRAPHIC_MODEto set the half graphic mode in RAM -
G_RAM_FULL_GRAPHIC_MODEto set the full graphic mode in RAM -
G_RAM_NOT_ALLOWED_MODEto represent the not allowed mode in RAM -
A_MASTER_ADDRESSto represent the master address -
A_SUB_ADDRESS_0to represent the sub address 0 -
A_SUB_ADDRESS_1to represent the sub address 1 -
A_SUB_ADDRESS_2to represent the sub address 2 -
DEVICE_ADDRESSto represent the device address -
COLUMN_ZERO_ADDRESSto represent the column zero address -
BANK_ZERO_ADDRESSto represent the bank zero address
You can use this script to convert characters to a map of characters and thier keycode. Type "esc" to escape the entering and start the converting.
This will ask you for dimentions and then start a gui window to create a screen. If you close the window it will output your result.
// TODO
The DesktopHttpClient class is a concrete implementation of the IHttpClient interface for desktop platforms. It uses the httplib library to perform HTTP requests.
You can create a DesktopHttpClient with the following methods:
-
DesktopHttpClient(std::string _base_url)to initialize the HTTP client with a base URL
Methods:
-
.get(std::string path, HttpRequest req)to perform a GET request to a specific path with a request object -
.post(std::string path, HttpRequest req)to perform a POST request to a specific path with a request object -
.set_bearer_auth_token(std::string token)to set the bearer token for authentication
The DesktopHttpClient class is defined in the DesktopHttpClient.h header file and implemented in the DesktopHttpClient.cpp source file. It uses the HttpRequest and HttpResponse classes for managing the HTTP requests and responses.
The IHttpClient class is an interface that defines the methods that an HTTP client should implement.
You can create an IHttpClient with the following methods:
-
IHttpClient(std::string _base_url)to initialize the HTTP client with a base URL
Methods:
-
.get(std::string path, HttpRequest req)to perform a GET request to a specific path with a request object (pure virtual method) -
.post(std::string path, HttpRequest req)to perform a POST request to a specific path with a request object (pure virtual method) -
.set_bearer_auth_token(std::string token)to set the bearer token for authentication (pure virtual method)
Note: The IHttpClient class is defined in the IHttpClient.h header file. It uses the HttpRequest and HttpResponse classes for managing the HTTP requests and responses.