move the Wrapper-Project out of the root directory and change readme and docs

This commit is contained in:
ZennDev1337 2023-08-16 12:08:25 +02:00
parent fd48cc36c5
commit 747ec6e9c9
19 changed files with 34 additions and 35 deletions

View file

@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View file

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

View file

@ -0,0 +1,21 @@
;PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:arduboy]
platform = atmelavr
board = arduboy
framework = arduino
build_flags =
-L lib -l libgame
lib_deps =
mlxxxp/Arduboy2@^6.0.0
ArduboyTones@^1.0.3

View file

@ -0,0 +1,195 @@
#pragma once
#include <Arduboy2.h>
extern Arduboy2 arduboy;
extern "C"
{
void arduboy_begin(void)
{
arduboy.begin();
}
void arduboy_clear(void)
{
arduboy.clear();
}
void arduboy_display(void)
{
arduboy.display();
}
void arduboy_display_and_clear_buffer(void)
{
arduboy.display(CLEAR_BUFFER);
}
void arduboy_draw_fast_hline(int16_t x, int16_t y, uint8_t w, uint8_t color)
{
arduboy.drawFastHLine(x, y, w, color);
}
void arduboy_draw_fast_vline(int16_t x, int16_t y, uint8_t h, uint8_t color)
{
arduboy.drawFastVLine(x, y, h, color);
}
void arduboy_draw_pixel(int16_t x, int16_t y, uint8_t color)
{
arduboy.drawPixel(x, y, color);
}
void arduboy_draw_circle(int16_t x, int16_t y, uint8_t r, uint8_t color)
{
arduboy.drawCircle(x, y, r, color);
}
void arduboy_fill_circle(int16_t x, int16_t y, uint8_t r, uint8_t color)
{
arduboy.fillCircle(x, y, r, color);
}
void arduboy_fill_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color)
{
arduboy.fillRect(x, y, w, h, color);
}
void arduboy_draw_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color)
{
arduboy.drawRect(x, y, w, h, color);
}
void arduboy_fill_round_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color)
{
arduboy.fillRoundRect(x, y, w, h, r, color);
}
void arduboy_draw_round_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color)
{
arduboy.drawRoundRect(x, y, w, h, r, color);
}
void arduboy_fill_triangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color)
{
arduboy.fillTriangle(x0, y0, x1, y1, x2, y2, color);
}
void arduboy_draw_triangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color)
{
arduboy.drawTriangle(x0, y0, x1, y1, x2, y2, color);
}
bool arduboy_every_x_frames(uint8_t frames)
{
return arduboy.everyXFrames(frames);
}
void arduboy_flip_horizontal(bool flipped)
{
arduboy.flipHorizontal(flipped);
}
void arduboy_flip_vertical(bool flipped)
{
arduboy.flipVertical(flipped);
}
void arduboy_set_text_color(uint8_t color)
{
arduboy.setTextColor(color);
}
void arduboy_set_text_background_color(uint8_t color)
{
arduboy.setTextBackground(color);
}
void arduboy_set_cursor_x(int16_t x)
{
arduboy.setCursorX(x);
}
void arduboy_set_cursor_y(int16_t y)
{
arduboy.setCursorY(y);
}
void arduboy_set_text_wrap(bool w)
{
arduboy.setTextWrap(w);
}
void arduboy_idle()
{
arduboy.idle();
}
unsigned long arduboy_generate_random_seed()
{
return arduboy.generateRandomSeed();
}
uint8_t arduboy_get_pixel(uint8_t x, uint8_t y)
{
return arduboy.getPixel(x, y);
}
void arduboy_init_random_seed(void)
{
arduboy.initRandomSeed();
}
bool arduboy_just_pressed(uint8_t button)
{
return arduboy.justPressed(button);
}
bool arduboy_just_released(uint8_t button)
{
return arduboy.justReleased(button);
}
bool arduboy_next_frame(void)
{
return arduboy.nextFrame();
}
void arduboy_poll_buttons()
{
arduboy.pollButtons();
}
bool arduboy_pressed(uint8_t buttons)
{
return arduboy.pressed(buttons);
}
void arduboy_print_chars(const char *cstr)
{
arduboy.print(cstr);
}
size_t arduboy_print_chars_progmem(const char *cstr)
{
return arduboy.print(reinterpret_cast<const __FlashStringHelper *>(cstr));
}
size_t arduboy_print_char(char c)
{
return arduboy.print(c);
}
size_t arduboy_print_int(int n, int base)
{
return arduboy.print(n, base);
}
size_t arduboy_print_long(long n, int base)
{
return arduboy.print(n, base);
}
size_t arduboy_print_unsigned_char(unsigned char n, int base)
{
return arduboy.print(n, base);
}
size_t arduboy_print_unsigned_int(unsigned int n, int base)
{
return arduboy.print(n, base);
}
size_t arduboy_print_unsigned_long(unsigned long n, int base)
{
return arduboy.print(n, base);
}
void arduboy_set_cursor(int16_t x, int16_t y)
{
arduboy.setCursor(x, y);
}
void arduboy_set_frame_rate(uint8_t rate)
{
arduboy.setFrameRate(rate);
}
bool arduboy_not_pressed(uint8_t button)
{
arduboy.notPressed(button);
}
void arduboy_set_text_size(uint8_t s)
{
arduboy.setTextSize(s);
}
void arduboy_invert(bool inverse)
{
arduboy.invert(inverse);
}
void arduboy_digital_write_rgb_single(uint8_t color, uint8_t val)
{
arduboy.digitalWriteRGB(color, val);
}
void arduboy_digital_write_rgb(uint8_t red, uint8_t green, uint8_t blue)
{
arduboy.digitalWriteRGB(red, green, blue);
}
}

View file

@ -0,0 +1,62 @@
#pragma once
#include <ArduboyTones.h>
#include <Arduboy2.h>
extern Arduboy2 arduboy;
ArduboyTones sound(arduboy.audio.enabled);
extern "C"
{
void arduboy_audio_on()
{
arduboy.audio.on();
}
void arduboy_audio_off()
{
arduboy.audio.off();
}
void arduboy_audio_toggle()
{
arduboy.audio.toggle();
}
void arduboy_audio_save_on_off()
{
arduboy.audio.saveOnOff();
}
bool arduboy_audio_enabled()
{
return arduboy.audio.enabled();
}
void sound_tone(unsigned int frequency, unsigned long duration)
{
sound.tone(frequency, duration);
}
void sound_tone2(unsigned int frequency1, unsigned long duration1, unsigned int frequency2, unsigned long duration2)
{
sound.tone(frequency1, duration1, frequency2, duration2);
}
void sound_tone3(unsigned int frequency1, unsigned long duration1, unsigned int frequency2, unsigned long duration2, unsigned int frequency3, unsigned long duration3)
{
sound.tone(frequency1, duration1, frequency2, duration2, frequency3, duration3);
}
void sound_tones(const uint16_t *tones)
{
sound.tones(tones);
}
void sound_no_tone()
{
sound.noTone();
}
bool sound_playing()
{
sound.playing();
}
void sound_tones_in_ram(uint16_t *tones)
{
sound.tonesInRAM(tones);
}
void sound_volume_mode(uint8_t mode)
{
sound.volumeMode(mode);
}
}

View file

@ -0,0 +1,27 @@
#pragma once
#include <Sprites.h>
extern "C"
{
void arduino_draw_override(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame)
{
Sprites::drawOverwrite(x, y, bitmap, frame);
}
void arduino_draw_external_mask(int16_t x, int16_t y, const uint8_t *bitmap,
const uint8_t *mask, uint8_t frame, uint8_t mask_frame)
{
Sprites::drawExternalMask(x, y, bitmap, mask, frame, mask_frame);
}
void arduino_draw_plus_mask(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame)
{
Sprites::drawPlusMask(x, y, bitmap, frame);
}
void arduino_draw_erase(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame)
{
Sprites::drawErase(x, y, bitmap, frame);
}
void arduino_draw_self_masked(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame)
{
Sprites::drawSelfMasked(x, y, bitmap, frame);
}
}

View file

@ -0,0 +1,18 @@
#pragma once
#include <Arduboy2.h>
extern "C"
{
long arduino_random_between(long min, long max)
{
return random(min, max);
}
long arduino_random_less_than(long max)
{
return random(max);
}
void arduino_delay(unsigned long ms)
{
delay(ms);
}
}

View file

@ -0,0 +1,26 @@
#pragma once
#include <avr/eeprom.h>
extern "C"
{
uint8_t arduboy_eeprom_read(int idx)
{
return eeprom_read_byte(reinterpret_cast<const uint8_t *>(idx));
}
void arduboy_eeprom_update(int idx, uint8_t val)
{
eeprom_update_byte(reinterpret_cast<uint8_t *>(idx), val);
}
void arduboy_eeprom_write(int idx, uint8_t val)
{
eeprom_write_byte(reinterpret_cast<uint8_t *>(idx), val);
}
void arduboy_eeprom_get(uint16_t address, uint8_t *object, size_t size)
{
eeprom_read_block(object, reinterpret_cast<const uint8_t *>(address), size);
}
void arduboy_eeprom_put(uint16_t address, const uint8_t *object, size_t size)
{
eeprom_update_block(object, reinterpret_cast<uint8_t *>(address), size);
}
}

View file

@ -0,0 +1 @@
#include "main.h"

View file

@ -0,0 +1,23 @@
#pragma once
#include "../../../import_config.h"
#if defined(Arduboy2_Library)
#include <Arduboy2.h>
Arduboy2 arduboy;
#include "./library/arduboy/arduboy_export.h"
#include "./library/arduboy/sprites_export.h"
#endif
#if defined(ArduboyTones_Library)
#include <ArduboyTones.h>
#include "./library/arduboy/arduboy_tones_export.h"
#endif
#if defined(Arduino_Library)
#include "./library/arduino/arduino_export.h"
#endif
#if defined(EEPROM_Library)
#include "./library/arduino/eeprom_export.h"
#endif

View file

@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html