first commit
This commit is contained in:
commit
c591b2c272
50 changed files with 2650 additions and 0 deletions
39
Wrapper-Project/include/README
Normal file
39
Wrapper-Project/include/README
Normal 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
|
46
Wrapper-Project/lib/README
Normal file
46
Wrapper-Project/lib/README
Normal 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
|
21
Wrapper-Project/platformio.ini
Normal file
21
Wrapper-Project/platformio.ini
Normal 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
|
123
Wrapper-Project/src/library/arduboy/arduboy.cpp
Normal file
123
Wrapper-Project/src/library/arduboy/arduboy.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
#include "arduboy.h"
|
||||
extern Arduboy2 arduboy;
|
||||
|
||||
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);
|
||||
}
|
||||
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_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);
|
||||
}
|
36
Wrapper-Project/src/library/arduboy/arduboy.h
Normal file
36
Wrapper-Project/src/library/arduboy/arduboy.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include <Arduboy2.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void arduboy_begin(void);
|
||||
void arduboy_clear(void);
|
||||
void arduboy_display(void);
|
||||
void arduboy_display_and_clear_buffer(void);
|
||||
void arduboy_draw_fast_hline(int16_t x, int16_t y, uint8_t w, uint8_t color);
|
||||
void arduboy_draw_fast_vline(int16_t x, int16_t y, uint8_t h, uint8_t color);
|
||||
void arduboy_draw_pixel(int16_t x, int16_t y, uint8_t color);
|
||||
void arduboy_draw_circle(int16_t x, int16_t y, uint8_t r, uint8_t color);
|
||||
void arduboy_fill_circle(int16_t x, int16_t y, uint8_t r, uint8_t color);
|
||||
void arduboy_fill_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color);
|
||||
unsigned long arduboy_generate_random_seed();
|
||||
uint8_t arduboy_get_pixel(uint8_t x, uint8_t y);
|
||||
void arduboy_init_random_seed(void);
|
||||
bool arduboy_just_pressed(uint8_t button);
|
||||
bool arduboy_just_released(uint8_t button);
|
||||
bool arduboy_next_frame(void);
|
||||
void arduboy_poll_buttons();
|
||||
bool arduboy_pressed(uint8_t buttons);
|
||||
void arduboy_print_chars(const char *cstr);
|
||||
size_t arduboy_print_char(char c);
|
||||
size_t arduboy_print_int(int n, int base);
|
||||
size_t arduboy_print_long(long n, int base);
|
||||
size_t arduboy_print_unsigned_char(unsigned char n, int base);
|
||||
size_t arduboy_print_unsigned_int(unsigned int n, int base);
|
||||
size_t arduboy_print_unsigned_long(unsigned long n, int base);
|
||||
void arduboy_set_cursor(int16_t x, int16_t y);
|
||||
void arduboy_set_frame_rate(uint8_t rate);
|
||||
bool arduboy_not_pressed(uint8_t button);
|
||||
void arduboy_set_text_size(uint8_t s);
|
||||
void arduboy_invert(bool inverse);
|
||||
}
|
46
Wrapper-Project/src/library/arduboy/arduboy_tones.cpp
Normal file
46
Wrapper-Project/src/library/arduboy/arduboy_tones.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include "arduboy_tones.h"
|
||||
|
||||
void arduboy_audio_on()
|
||||
{
|
||||
arduboy.audio.on();
|
||||
}
|
||||
void arduboy_audio_off()
|
||||
{
|
||||
arduboy.audio.off();
|
||||
}
|
||||
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);
|
||||
}
|
21
Wrapper-Project/src/library/arduboy/arduboy_tones.h
Normal file
21
Wrapper-Project/src/library/arduboy/arduboy_tones.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include <ArduboyTones.h>
|
||||
#include <Arduboy2.h>
|
||||
extern ArduboyTones sound;
|
||||
extern Arduboy2 arduboy;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void arduboy_audio_on();
|
||||
void arduboy_audio_off();
|
||||
bool arduboy_audio_enabled();
|
||||
void sound_tone(unsigned int frequency, unsigned long duration);
|
||||
void sound_tone2(unsigned int frequency1, unsigned long duration1, unsigned int frequency2, unsigned long duration2);
|
||||
void sound_tone3(unsigned int frequency1, unsigned long duration1, unsigned int frequency2, unsigned long duration2, unsigned int frequency3, unsigned long duration3);
|
||||
void sound_tones(const uint16_t *tones);
|
||||
void sound_no_tone();
|
||||
bool sound_playing();
|
||||
void sound_tones_in_ram(uint16_t *tones);
|
||||
void sound_volume_mode(uint8_t mode);
|
||||
}
|
6
Wrapper-Project/src/library/arduboy/sprites.cpp
Normal file
6
Wrapper-Project/src/library/arduboy/sprites.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "sprites.h"
|
||||
|
||||
void arduino_draw_override(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame)
|
||||
{
|
||||
Sprites::drawOverwrite(x, y, bitmap, frame);
|
||||
}
|
7
Wrapper-Project/src/library/arduboy/sprites.h
Normal file
7
Wrapper-Project/src/library/arduboy/sprites.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
#include <Sprites.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void arduino_draw_override(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame);
|
||||
}
|
14
Wrapper-Project/src/library/arduino/arduino.cpp
Normal file
14
Wrapper-Project/src/library/arduino/arduino.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "arduino.h"
|
||||
|
||||
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);
|
||||
}
|
9
Wrapper-Project/src/library/arduino/arduino.h
Normal file
9
Wrapper-Project/src/library/arduino/arduino.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
#include <Arduboy2.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
long arduino_random_between(long min, long max);
|
||||
long arduino_random_less_than(long max);
|
||||
void arduino_delay(unsigned long ms);
|
||||
}
|
26
Wrapper-Project/src/library/arduino/eeprom.cpp
Normal file
26
Wrapper-Project/src/library/arduino/eeprom.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "eeprom.h"
|
||||
|
||||
int eeprom;
|
||||
|
||||
uint8_t arduboy_eeprom_read(int idx)
|
||||
{
|
||||
eeprom = EEPROM.read(idx);
|
||||
return eeprom;
|
||||
}
|
||||
void arduboy_eeprom_update(int idx, uint8_t val)
|
||||
{
|
||||
EEPROM.update(idx, val);
|
||||
}
|
||||
void arduboy_eeprom_write(int idx, uint8_t val)
|
||||
{
|
||||
EEPROM.write(idx, val);
|
||||
}
|
||||
uint8_t arduboy_eeprom_get(int idx)
|
||||
{
|
||||
EEPROM.get(idx, eeprom);
|
||||
return eeprom;
|
||||
}
|
||||
void arduboy_eeprom_put(int idx, uint8_t val)
|
||||
{
|
||||
EEPROM.put(idx, val);
|
||||
}
|
12
Wrapper-Project/src/library/arduino/eeprom.h
Normal file
12
Wrapper-Project/src/library/arduino/eeprom.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
uint8_t arduboy_eeprom_read(int idx);
|
||||
void arduboy_eeprom_update(int idx, uint8_t val);
|
||||
void arduboy_eeprom_write(int idx, uint8_t val);
|
||||
uint8_t arduboy_eeprom_get(int idx);
|
||||
void arduboy_eeprom_put(int idx, uint8_t val);
|
||||
}
|
4
Wrapper-Project/src/main.cpp
Normal file
4
Wrapper-Project/src/main.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "main.h"
|
||||
|
||||
Arduboy2 arduboy;
|
||||
ArduboyTones sound(arduboy.audio.enabled);
|
9
Wrapper-Project/src/main.h
Normal file
9
Wrapper-Project/src/main.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduboy2.h>
|
||||
#include <ArduboyTones.h>
|
||||
#include "./library/arduboy/arduboy.h"
|
||||
#include "./library/arduboy/sprites.h"
|
||||
#include "./library/arduboy/arduboy_tones.h"
|
||||
#include "./library/arduino/arduino.h"
|
||||
#include "./library/arduino/eeprom.h"
|
11
Wrapper-Project/test/README
Normal file
11
Wrapper-Project/test/README
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue