Compare commits
100 commits
waveplayer
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19f707488a | ||
|
|
54494a0d36 | ||
|
|
21601d6341 | ||
|
|
cdda88c474 | ||
|
|
4ddc5ef240 | ||
|
|
06c36376b1 | ||
|
|
5de481f4f3 | ||
|
|
2ced4fe55f | ||
|
|
55a27f7847 | ||
|
|
f7e3da6bfd | ||
|
|
d678db359d | ||
|
|
9e04237fa2 | ||
|
|
24b2a97d15 | ||
|
|
08f1730cc1 | ||
|
|
78156b8b99 | ||
|
|
12bf3e2039 | ||
|
|
899682b649 | ||
|
|
d3fb35d6c2 | ||
|
|
3b94c71ff7 | ||
|
|
e97b767a02 | ||
|
|
eaeaefa4d1 | ||
|
|
3dcc52367a | ||
|
|
66c5802625 | ||
|
|
3cb47d0afe | ||
|
|
0a956ca7f3 | ||
|
|
32500cf224 | ||
|
|
47f197897c | ||
|
|
db4416c32f | ||
|
|
4f2029a00c | ||
|
|
5cc06c384c | ||
|
|
0e714ff2e1 | ||
|
|
1bb82951af | ||
|
|
303f5b3c47 | ||
|
|
784a8bcc91 | ||
|
|
96294e931c | ||
|
|
e30fb5c3be | ||
|
|
cead95f07a | ||
|
|
39c7512ad7 | ||
|
|
70b6cc421c | ||
|
|
ba4bc1ca85 | ||
|
|
0f1c2be754 | ||
|
|
12a517d795 | ||
|
|
9574e7337b | ||
|
|
3e21a1e2a4 | ||
|
|
ef44bd3e26 | ||
|
|
546d539a25 | ||
|
|
890f40ddb9 | ||
|
|
22a3ea3c11 | ||
|
|
40b4f8ab4f | ||
|
|
1121c2955f | ||
|
|
9efb621c3d | ||
|
|
abcb08a4a2 | ||
|
|
c98ca72edb | ||
|
|
cbd2cd0fb4 | ||
|
|
fe38733a40 | ||
|
|
268fc9398b | ||
|
|
33718b47cf | ||
|
|
28739e8198 | ||
|
|
0bd09a81a3 | ||
|
|
ac3ebfe2a4 | ||
|
|
6256e6d30f | ||
|
|
38411b08e6 | ||
|
|
6981227c50 | ||
|
|
efcd4a7c1a | ||
|
|
d0ed0c25a9 | ||
|
|
5b1ff3043c | ||
|
|
d4e9dd9568 | ||
|
|
7d49c326a8 | ||
|
|
c9a039d770 | ||
|
|
9f3cdcffcc | ||
|
|
d67bed5839 | ||
|
|
848fed56f9 | ||
|
|
3dd23545bf | ||
|
|
fcc17b9446 | ||
|
|
7a547b00a5 | ||
|
|
2b016c93d5 | ||
|
|
104b0f0ca9 | ||
|
|
322f6ae63a | ||
|
|
d9bb7510c3 | ||
|
|
e722595596 | ||
|
|
4c73578e6d | ||
|
|
3f1b061c60 | ||
|
|
34b5c1f3cc | ||
|
|
e94043b928 | ||
|
|
c628034b60 | ||
|
|
9285f1a8ed | ||
|
|
ebdb777e08 | ||
|
|
4caf4d11e7 | ||
|
|
cd53e93fbf | ||
|
|
8baf7f28d6 | ||
|
|
2ec297b1c5 | ||
|
|
4b7856fafa | ||
|
|
2551ca332a | ||
|
|
81023a9815 | ||
|
|
a3ae6b7972 | ||
|
|
617a5c37d1 | ||
|
|
20f5b3c24b | ||
|
|
396a1cbfee | ||
|
|
d76834aa58 | ||
|
|
65f24943ef |
88 changed files with 16835 additions and 8501 deletions
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
||||
63
.github/workflows/githubci.yml
vendored
Normal file
63
.github/workflows/githubci.yml
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
clang_and_doxy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run pre-commit
|
||||
uses: pre-commit/action@v3.0.1
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
# - name: clang
|
||||
# run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit Arcada Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
||||
|
||||
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arduino-platform: ["pybadge", "pybadge_tinyusb", "pygamer", "pyportal",
|
||||
"hallowing_m4", "hallowing_m0", "clue",
|
||||
"monster_m4sk", "cpx_ada", "pyportal_titano"]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
needs: clang_and_doxy
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
# manually install WiFi
|
||||
- name: extra libraries
|
||||
run: |
|
||||
git clone --quiet https://github.com/adafruit/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}
|
||||
|
||||
|
||||
11
.pre-commit-config.yaml
Normal file
11
.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v15.0.7
|
||||
hooks:
|
||||
- id: clang-format
|
||||
types_or: [c++, c, header]
|
||||
exclude: \.ino$
|
||||
49
.travis.yml
49
.travis.yml
|
|
@ -1,49 +0,0 @@
|
|||
language: c
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- ~/arduino_ide
|
||||
- ~/.arduino15/packages/
|
||||
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
|
||||
env:
|
||||
global:
|
||||
- PRETTYNAME="Adafruit Arcada Library"
|
||||
|
||||
before_install:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
|
||||
|
||||
install:
|
||||
- rm -rf $HOME/arduino_ide/libraries/Adafruit_Circuit_Playground
|
||||
- arduino --install-library "Adafruit Unified Sensor"
|
||||
- arduino --install-library "Adafruit NeoPixel"
|
||||
- arduino --install-library "Adafruit ADT7410 Library"
|
||||
- arduino --install-library "Adafruit GFX Library"
|
||||
- arduino --install-library "Adafruit ST7735 and ST7789 Library"
|
||||
- arduino --install-library "Adafruit ILI9341"
|
||||
- arduino --install-library "Adafruit SPIFlash"
|
||||
- arduino --install-library "Adafruit LIS3DH"
|
||||
- arduino --install-library "Adafruit ZeroTimer Library"
|
||||
- arduino --install-library "Adafruit TouchScreen"
|
||||
- arduino --install-library "Adafruit MSA301"
|
||||
- arduino --install-library "Adafruit BusIO"
|
||||
- arduino --install-library "Adafruit PixelDust"
|
||||
- arduino --install-library "ArduinoJson"
|
||||
- arduino --install-library "Adafruit ImageReader Library"
|
||||
- arduino --install-library "Adafruit WavePlayer Library"
|
||||
- arduino --install-library "Adafruit TinyUSB Library"
|
||||
- arduino --install-library "SdFat - Adafruit Fork"
|
||||
- arduino --install-library "Adafruit Circuit Playground"
|
||||
- git clone --quiet https://github.com/adafruit/WiFiNINA.git $HOME/Arduino/libraries/WiFiNINA
|
||||
- git clone --quiet https://github.com/adafruit/Audio.git $HOME/Arduino/libraries/Audio
|
||||
|
||||
script:
|
||||
- build_arcada_platforms
|
||||
|
||||
after_success:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
|
||||
|
||||
|
||||
#if defined(__SAMD51__)
|
||||
#if defined(ARCADA_CALLBACKTIMER) && defined(__SAMD51__)
|
||||
static Adafruit_ZeroTimer zerotimer = Adafruit_ZeroTimer(ARCADA_CALLBACKTIMER);
|
||||
|
||||
void ARCADA_CALLBACKTIMER_HANDLER() {
|
||||
|
|
@ -10,13 +8,23 @@ void ARCADA_CALLBACKTIMER_HANDLER() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(NRF52_SERIES)
|
||||
void (*nrf52_callback)() = NULL;
|
||||
extern "C" {
|
||||
void SysTick_Handler(void) {
|
||||
if (nrf52_callback != NULL)
|
||||
nrf52_callback();
|
||||
}
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Instantiator for Arcada class, will allso inistantiate (but not init) the TFT
|
||||
@brief Instantiator for Arcada class, will allso inistantiate (but not
|
||||
init) the TFT
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_Arcada_SPITFT::Adafruit_Arcada_SPITFT()
|
||||
{
|
||||
Adafruit_Arcada_SPITFT::Adafruit_Arcada_SPITFT() {
|
||||
_sd_cs = ARCADA_SD_CS;
|
||||
_speaker_en = ARCADA_SPEAKER_ENABLE;
|
||||
_neopixel_pin = ARCADA_NEOPIXEL_PIN;
|
||||
|
|
@ -67,7 +75,8 @@ Adafruit_Arcada_SPITFT::Adafruit_Arcada_SPITFT()
|
|||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::arcadaBegin(void) {
|
||||
if (! variantBegin()) return false;
|
||||
if (!variantBegin())
|
||||
return false;
|
||||
|
||||
setBacklight(0);
|
||||
|
||||
|
|
@ -94,15 +103,15 @@ bool Adafruit_Arcada_SPITFT::arcadaBegin(void) {
|
|||
delay(10);
|
||||
pixels.setBrightness(20);
|
||||
pixels.fill(0);
|
||||
pixels.show(); // turn off
|
||||
pixels.show(); // turn off
|
||||
delay(10);
|
||||
pixels.show(); // turn off
|
||||
pixels.show(); // turn off
|
||||
}
|
||||
|
||||
_touchscreen = NULL;
|
||||
if (_touch_xp >= 0) {
|
||||
_touchscreen = new TouchScreen(_touch_xp, _touch_yp,
|
||||
_touch_xm, _touch_ym, 300);
|
||||
_touchscreen =
|
||||
new TouchScreen(_touch_xp, _touch_yp, _touch_xm, _touch_ym, 300);
|
||||
setTouchscreenCalibration(_ts_xmin, _ts_xmax, _ts_ymin, _ts_ymax);
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +139,7 @@ bool Adafruit_Arcada_SPITFT::arcadaBegin(void) {
|
|||
if (_right_button >= 0) {
|
||||
pinMode(_right_button, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
|
||||
if (_button_clock >= 0) {
|
||||
pinMode(_button_clock, OUTPUT);
|
||||
digitalWrite(_button_clock, HIGH);
|
||||
|
|
@ -143,7 +152,6 @@ bool Adafruit_Arcada_SPITFT::arcadaBegin(void) {
|
|||
pinMode(_button_data, INPUT);
|
||||
}
|
||||
|
||||
|
||||
#ifndef SPIWIFI
|
||||
_has_wifi = false;
|
||||
#else
|
||||
|
|
@ -151,8 +159,7 @@ bool Adafruit_Arcada_SPITFT::arcadaBegin(void) {
|
|||
delay(100);
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
_has_wifi = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_has_wifi = true;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -163,12 +170,12 @@ bool Adafruit_Arcada_SPITFT::arcadaBegin(void) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the backlight brightness and save to the configuration
|
||||
@param brightness From 0 (off) to 255 (full on)
|
||||
@param saveToDisk Whether we save this permanently to disk, default is false
|
||||
@param saveToDisk Whether we save this permanently to disk, default is
|
||||
false
|
||||
@returns Whether saving to disk succeeded, or true if we don't save
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
|
@ -190,25 +197,23 @@ bool Adafruit_Arcada_SPITFT::setBacklight(uint8_t brightness, bool saveToDisk) {
|
|||
return saveConfigurationFile();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get the backlight brightness
|
||||
@returns brightness From 0 (off) to 255 (full on)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Arcada_SPITFT::getBacklight(void) {
|
||||
return _brightness;
|
||||
}
|
||||
uint8_t Adafruit_Arcada_SPITFT::getBacklight(void) { return _brightness; }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the audio volume (not working at this time)
|
||||
@param volume From 0 (off) to 255 (full on)
|
||||
@param saveToDisk Whether we save this permanently to disk, default is false
|
||||
@param saveToDisk Whether we save this permanently to disk, default is
|
||||
false
|
||||
@returns Whether saving to disk succeeded, or true if we don't save
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
|
@ -220,7 +225,7 @@ bool Adafruit_Arcada_SPITFT::setVolume(uint8_t volume, bool saveToDisk) {
|
|||
return saveConfigurationFile();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -229,9 +234,7 @@ bool Adafruit_Arcada_SPITFT::setVolume(uint8_t volume, bool saveToDisk) {
|
|||
@returns Volume From 0 (off) to 255 (full on)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Arcada_SPITFT::getVolume(void) {
|
||||
return _volume;
|
||||
}
|
||||
uint8_t Adafruit_Arcada_SPITFT::getVolume(void) { return _volume; }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -248,13 +251,13 @@ void Adafruit_Arcada_SPITFT::enableSpeaker(bool on) {
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Create a repetative callback to a function using a timer
|
||||
@param freq The callback frequency, must be between 0.75 Hz and 24MHz (slower is better)
|
||||
@param freq The callback frequency, must be between 0.75 Hz and 24MHz
|
||||
(slower is better)
|
||||
@param callback A pointer to the function we'll call every time
|
||||
@return True on success, False if something failed!
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::timerCallback(float freq, void (*callback)()) {
|
||||
|
||||
#if defined(__SAMD51__)
|
||||
Serial.printf("Desired freq: %f Hz\n", freq);
|
||||
uint16_t divider = 1;
|
||||
|
|
@ -264,57 +267,63 @@ bool Adafruit_Arcada_SPITFT::timerCallback(float freq, void (*callback)()) {
|
|||
if ((freq < 24000000) && (freq > 800)) {
|
||||
divider = 1;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV1;
|
||||
compare = 48000000/freq;
|
||||
compare = 48000000 / freq;
|
||||
} else if (freq > 400) {
|
||||
divider = 2;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV2;
|
||||
compare = (48000000/2)/freq;
|
||||
compare = (48000000 / 2) / freq;
|
||||
} else if (freq > 200) {
|
||||
divider = 4;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV4;
|
||||
compare = (48000000/4)/freq;
|
||||
compare = (48000000 / 4) / freq;
|
||||
} else if (freq > 100) {
|
||||
divider = 8;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV8;
|
||||
compare = (48000000/8)/freq;
|
||||
compare = (48000000 / 8) / freq;
|
||||
} else if (freq > 50) {
|
||||
divider = 16;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV16;
|
||||
compare = (48000000/16)/freq;
|
||||
compare = (48000000 / 16) / freq;
|
||||
} else if (freq > 12) {
|
||||
divider = 64;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV64;
|
||||
compare = (48000000/64)/freq;
|
||||
compare = (48000000 / 64) / freq;
|
||||
} else if (freq > 3) {
|
||||
divider = 256;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV256;
|
||||
compare = (48000000/256)/freq;
|
||||
compare = (48000000 / 256) / freq;
|
||||
} else if (freq >= 0.75) {
|
||||
divider = 1024;
|
||||
prescaler = TC_CLOCK_PRESCALER_DIV1024;
|
||||
compare = (48000000/1024)/freq;
|
||||
compare = (48000000 / 1024) / freq;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
_callback_freq = ((48000000.0/(float)divider) / (float)compare);
|
||||
_callback_freq = ((48000000.0 / (float)divider) / (float)compare);
|
||||
_callback_func = callback;
|
||||
|
||||
Serial.printf("Divider %d / compare %d -> %f Hz\n",
|
||||
divider, compare, _callback_freq);
|
||||
// Serial.printf("Divider %d / compare %d -> %f Hz\n",
|
||||
// divider, compare, _callback_freq);
|
||||
|
||||
zerotimer.enable(false);
|
||||
zerotimer.configure(prescaler, // prescaler
|
||||
TC_COUNTER_SIZE_16BIT, // bit width of timer/counter
|
||||
TC_WAVE_GENERATION_MATCH_PWM // frequency or PWM mode
|
||||
);
|
||||
zerotimer.configure(prescaler, // prescaler
|
||||
TC_COUNTER_SIZE_16BIT, // bit width of timer/counter
|
||||
TC_WAVE_GENERATION_MATCH_PWM // frequency or PWM mode
|
||||
);
|
||||
|
||||
zerotimer.setCompare(0, compare);
|
||||
zerotimer.setCallback(true, TC_CALLBACK_CC_CHANNEL0, callback);
|
||||
zerotimer.enable(true);
|
||||
return true;
|
||||
#elif defined(NRF52_SERIES)
|
||||
SysTick_Config(F_CPU / freq);
|
||||
nrf52_callback = callback;
|
||||
return true;
|
||||
#else
|
||||
return false; // not supported (yet)!
|
||||
(void)freq;
|
||||
(void)callback;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +356,6 @@ arcada_callback_t Adafruit_Arcada_SPITFT::getTimerCallback(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Stop a previously-initiated timer.
|
||||
|
|
@ -368,9 +376,9 @@ void Adafruit_Arcada_SPITFT::timerStop(void) {
|
|||
void Adafruit_Arcada_SPITFT::printf(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
|
||||
Serial.printf(format, args);
|
||||
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +393,7 @@ int16_t Adafruit_Arcada_SPITFT::readJoystickX(uint8_t sampling) {
|
|||
|
||||
float reading = 0;
|
||||
if (_joystick_x >= 0) {
|
||||
for (int i=0; i<sampling; i++) {
|
||||
for (int i = 0; i < sampling; i++) {
|
||||
reading += analogRead(_joystick_x);
|
||||
}
|
||||
reading /= sampling;
|
||||
|
|
@ -407,11 +415,11 @@ int16_t Adafruit_Arcada_SPITFT::readJoystickY(uint8_t sampling) {
|
|||
|
||||
float reading = 0;
|
||||
if (_joystick_y >= 0) {
|
||||
for (int i=0; i<sampling; i++) {
|
||||
for (int i = 0; i < sampling; i++) {
|
||||
reading += analogRead(_joystick_y);
|
||||
}
|
||||
reading /= sampling;
|
||||
|
||||
|
||||
// adjust range from 0->1024 to -512 to 511;
|
||||
reading -= _joyy_center;
|
||||
}
|
||||
|
|
@ -421,13 +429,14 @@ int16_t Adafruit_Arcada_SPITFT::readJoystickY(uint8_t sampling) {
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Read all buttons/joystick and return a bitmask of which buttons are
|
||||
pressed, check ARCADA_BUTTONMASK_* for valid bitmasks to check again.
|
||||
If there's an analog joystick, it will 'simulate' the button presses.
|
||||
pressed, check ARCADA_BUTTONMASK_* for valid bitmasks to check
|
||||
again. If there's an analog joystick, it will 'simulate' the button presses.
|
||||
@return Bit array with up to 32 buttons, 1 for pressed, 0 for not.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint32_t Adafruit_Arcada_SPITFT::readButtons(void) {
|
||||
uint32_t buttons = variantReadButtons(); // start with whatever the variant can do
|
||||
uint32_t buttons =
|
||||
variantReadButtons(); // start with whatever the variant can do
|
||||
|
||||
// Use a latch to read 8 bits
|
||||
if (_button_clock >= 0) {
|
||||
|
|
@ -436,8 +445,8 @@ uint32_t Adafruit_Arcada_SPITFT::readButtons(void) {
|
|||
delayMicroseconds(1);
|
||||
digitalWrite(_button_latch, HIGH);
|
||||
delayMicroseconds(1);
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
shift_buttons <<= 1;
|
||||
shift_buttons |= digitalRead(_button_data);
|
||||
digitalWrite(_button_clock, HIGH);
|
||||
|
|
@ -445,7 +454,7 @@ uint32_t Adafruit_Arcada_SPITFT::readButtons(void) {
|
|||
digitalWrite(_button_clock, LOW);
|
||||
delayMicroseconds(1);
|
||||
}
|
||||
|
||||
|
||||
if (shift_buttons & _shift_b)
|
||||
buttons |= ARCADA_BUTTONMASK_B;
|
||||
if (shift_buttons & _shift_a)
|
||||
|
|
@ -465,19 +474,19 @@ uint32_t Adafruit_Arcada_SPITFT::readButtons(void) {
|
|||
}
|
||||
|
||||
// GPIO buttons!
|
||||
if ((_start_button >= 0) && !digitalRead(_start_button))
|
||||
if ((_start_button >= 0) && !digitalRead(_start_button))
|
||||
buttons |= ARCADA_BUTTONMASK_START;
|
||||
|
||||
if ((_select_button >= 0) && !digitalRead(_select_button))
|
||||
if ((_select_button >= 0) && !digitalRead(_select_button))
|
||||
buttons |= ARCADA_BUTTONMASK_SELECT;
|
||||
|
||||
if ((_a_button >= 0) && !digitalRead(_a_button))
|
||||
if ((_a_button >= 0) && !digitalRead(_a_button))
|
||||
buttons |= ARCADA_BUTTONMASK_A;
|
||||
|
||||
if ((_b_button >= 0) && !digitalRead(_b_button))
|
||||
if ((_b_button >= 0) && !digitalRead(_b_button))
|
||||
buttons |= ARCADA_BUTTONMASK_B;
|
||||
|
||||
if ((_up_button >= 0) && !digitalRead(_up_button))
|
||||
if ((_up_button >= 0) && !digitalRead(_up_button))
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
if ((_down_button >= 0) && !digitalRead(_down_button))
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
|
|
@ -488,48 +497,56 @@ uint32_t Adafruit_Arcada_SPITFT::readButtons(void) {
|
|||
|
||||
// Potentiometers for X & Y
|
||||
int16_t x = readJoystickX(); // returns 0 on no joystick
|
||||
if (x > 350)
|
||||
if (x > 350)
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT;
|
||||
else if (x < -350)
|
||||
else if (x < -350)
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT;
|
||||
int16_t y = readJoystickY(); // returns 0 on no joystick
|
||||
if (y > 350)
|
||||
if (y > 350)
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
else if (y < -350)
|
||||
else if (y < -350)
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
|
||||
// Touchscreen
|
||||
if (_touchscreen) {
|
||||
TSPoint p = getTouchscreenPoint();
|
||||
if (p.z > 100) {
|
||||
//Serial.printf("(%d, %d)\n", p.x, p.y);
|
||||
// Serial.printf("(%d, %d)\n", p.x, p.y);
|
||||
// up!
|
||||
if ( (p.y < display->height()/4) && (p.x > display->width()/4) && (p.x < (display->width()*3.0/4.0)) ) {
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
if ((p.y < display->height() / 4) && (p.x > display->width() / 4) &&
|
||||
(p.x < (display->width() * 3.0 / 4.0))) {
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
}
|
||||
// down!
|
||||
if ( (p.y > (display->height()*3.0/4.0)) &&
|
||||
(p.x > display->width()/3) && (p.x < (display->width()*3.0/4.0)) ) {
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
if ((p.y > (display->height() * 3.0 / 4.0)) &&
|
||||
(p.x > display->width() / 3) &&
|
||||
(p.x < (display->width() * 3.0 / 4.0))) {
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
}
|
||||
// left!
|
||||
if ( (p.x < display->width()/4) && (p.y > display->height()/4) && (p.y < (display->height()*3.0/4.0)) ) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT;
|
||||
if ((p.x < display->width() / 4) && (p.y > display->height() / 4) &&
|
||||
(p.y < (display->height() * 3.0 / 4.0))) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT;
|
||||
}
|
||||
// right!
|
||||
if ( (p.x > (display->width()*3.0/4.0)) &&
|
||||
(p.y > display->height()/4) && (p.y < (display->height()*3.0/4.0)) ) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT;
|
||||
if ((p.x > (display->width() * 3.0 / 4.0)) &&
|
||||
(p.y > display->height() / 4) &&
|
||||
(p.y < (display->height() * 3.0 / 4.0))) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT;
|
||||
}
|
||||
// B
|
||||
if ( (p.x > display->width()/4) && (p.x < display->width()/2) // 2nd quarter
|
||||
&& (p.y > display->height()/4) && (p.y < (display->height()*3.0/4.0)) ) {
|
||||
buttons |= ARCADA_BUTTONMASK_B;
|
||||
if ((p.x > display->width() / 4) &&
|
||||
(p.x < display->width() / 2) // 2nd quarter
|
||||
&& (p.y > display->height() / 4) &&
|
||||
(p.y < (display->height() * 3.0 / 4.0))) {
|
||||
buttons |= ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
// A
|
||||
if ( (p.x > display->width()/2) && (p.x < (display->width()*3.0/4.0)) // 3rd quarter
|
||||
&& (p.y > display->height()/4) && (p.y < (display->height()*3.0/4.0)) ) {
|
||||
buttons |= ARCADA_BUTTONMASK_A;
|
||||
if ((p.x > display->width() / 2) &&
|
||||
(p.x < (display->width() * 3.0 / 4.0)) // 3rd quarter
|
||||
&& (p.y > display->height() / 4) &&
|
||||
(p.y < (display->height() * 3.0 / 4.0))) {
|
||||
buttons |= ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -538,29 +555,31 @@ uint32_t Adafruit_Arcada_SPITFT::readButtons(void) {
|
|||
curr_buttons = buttons;
|
||||
justpressed_buttons = (last_buttons ^ curr_buttons) & curr_buttons;
|
||||
justreleased_buttons = (last_buttons ^ curr_buttons) & last_buttons;
|
||||
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief What buttons were just pressed as of the last readButtons() call.
|
||||
Use ARCADA_BUTTONMASK_* defines to extract which bits are true (just pressed)
|
||||
Use ARCADA_BUTTONMASK_* defines to extract which bits are true (just
|
||||
pressed)
|
||||
@return Bitmask of all buttons that were just pressed
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint32_t Adafruit_Arcada_SPITFT::justPressedButtons(void) {
|
||||
uint32_t Adafruit_Arcada_SPITFT::justPressedButtons(void) {
|
||||
return justpressed_buttons;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief What buttons were just released as of the last readButtons() call.
|
||||
Use ARCADA_BUTTONMASK_* defines to extract which bits are true (just releasd)
|
||||
Use ARCADA_BUTTONMASK_* defines to extract which bits are true (just
|
||||
releasd)
|
||||
@return Bitmask of all buttons that were just released
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint32_t Adafruit_Arcada_SPITFT::justReleasedButtons(void) {
|
||||
uint32_t Adafruit_Arcada_SPITFT::justReleasedButtons(void) {
|
||||
return justreleased_buttons;
|
||||
}
|
||||
|
||||
|
|
@ -586,7 +605,7 @@ uint16_t Adafruit_Arcada_SPITFT::readLightSensor(void) {
|
|||
/**************************************************************************/
|
||||
float Adafruit_Arcada_SPITFT::readBatterySensor(void) {
|
||||
if (_battery_sensor >= 0) {
|
||||
return ( (float)analogRead(_battery_sensor) / 1023.0) * 2.0 * 3.3 ;
|
||||
return ((float)analogRead(_battery_sensor) / 1023.0) * 2.0 * 3.3;
|
||||
} else {
|
||||
return NAN;
|
||||
}
|
||||
|
|
@ -600,8 +619,10 @@ float Adafruit_Arcada_SPITFT::readBatterySensor(void) {
|
|||
@return True on success (could allocate) or false on failure
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::createFrameBuffer(uint16_t width, uint16_t height) {
|
||||
if(_canvas) delete(_canvas);
|
||||
bool Adafruit_Arcada_SPITFT::createFrameBuffer(uint16_t width,
|
||||
uint16_t height) {
|
||||
if (_canvas)
|
||||
delete (_canvas);
|
||||
_canvas = new GFXcanvas16(width, height);
|
||||
return (_canvas != NULL);
|
||||
}
|
||||
|
|
@ -638,13 +659,14 @@ bool Adafruit_Arcada_SPITFT::createFrameBuffer(uint16_t width, uint16_t height)
|
|||
framebuffer until the transfer completes).
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::blitFrameBuffer(uint16_t x, uint16_t y, bool blocking,
|
||||
bool bigEndian, Adafruit_SPITFT *blitdisplay) {
|
||||
if (! blitdisplay) {
|
||||
bool Adafruit_Arcada_SPITFT::blitFrameBuffer(uint16_t x, uint16_t y,
|
||||
bool blocking, bool bigEndian,
|
||||
Adafruit_SPITFT *blitdisplay) {
|
||||
if (!blitdisplay) {
|
||||
blitdisplay = display;
|
||||
}
|
||||
if(_canvas) {
|
||||
if (! _first_frame) {
|
||||
if (_canvas) {
|
||||
if (!_first_frame) {
|
||||
blitdisplay->dmaWait(); // Wait for prior DMA transfer to complete
|
||||
blitdisplay->endWrite(); // End transaction from any prior call
|
||||
} else {
|
||||
|
|
@ -652,8 +674,9 @@ bool Adafruit_Arcada_SPITFT::blitFrameBuffer(uint16_t x, uint16_t y, bool blocki
|
|||
}
|
||||
blitdisplay->startWrite(); // Start new display transaction
|
||||
blitdisplay->setAddrWindow(x, y, _canvas->width(), _canvas->height());
|
||||
blitdisplay->writePixels(_canvas->getBuffer(), _canvas->width() * _canvas->height(),
|
||||
blocking, bigEndian);
|
||||
blitdisplay->writePixels(_canvas->getBuffer(),
|
||||
_canvas->width() * _canvas->height(), blocking,
|
||||
bigEndian);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -666,9 +689,7 @@ bool Adafruit_Arcada_SPITFT::blitFrameBuffer(uint16_t x, uint16_t y, bool blocki
|
|||
@returns True if it does
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::hasTouchscreen(void) {
|
||||
return (_touch_xp >= 0);
|
||||
}
|
||||
bool Adafruit_Arcada_SPITFT::hasTouchscreen(void) { return (_touch_xp >= 0); }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -679,8 +700,10 @@ bool Adafruit_Arcada_SPITFT::hasTouchscreen(void) {
|
|||
@param ymax The value of Y which corresponds to the TFT height on that axis
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_Arcada_SPITFT::setTouchscreenCalibration(int16_t xmin, int16_t xmax,
|
||||
int16_t ymin, int16_t ymax) {
|
||||
void Adafruit_Arcada_SPITFT::setTouchscreenCalibration(int16_t xmin,
|
||||
int16_t xmax,
|
||||
int16_t ymin,
|
||||
int16_t ymax) {
|
||||
_ts_xmin = xmin;
|
||||
_ts_xmax = xmax;
|
||||
_ts_ymin = ymin;
|
||||
|
|
@ -702,12 +725,12 @@ TSPoint Adafruit_Arcada_SPITFT::getTouchscreenPoint(void) {
|
|||
}
|
||||
|
||||
TSPoint points[8];
|
||||
for (int i=0; i<8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
points[i] = _touchscreen->getPoint(); // the uncalibrated point
|
||||
}
|
||||
bool invalid = true;
|
||||
TSPoint p;
|
||||
for (int i=0; i<8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if ((points[i].z > 100) && (points[i].z < 1000)) {
|
||||
p.x = points[i].x;
|
||||
p.y = points[i].y;
|
||||
|
|
@ -720,7 +743,7 @@ TSPoint Adafruit_Arcada_SPITFT::getTouchscreenPoint(void) {
|
|||
return p;
|
||||
}
|
||||
|
||||
//Serial.printf("rot: %d (%d, %d) \t", getRotation(), p.x, p.y);
|
||||
// Serial.printf("rot: %d (%d, %d) \t", getRotation(), p.x, p.y);
|
||||
|
||||
if (display->getRotation() == 0) {
|
||||
int _y = map(p.y, _ts_ymin, _ts_ymax, 0, display->height());
|
||||
|
|
@ -749,10 +772,10 @@ TSPoint Adafruit_Arcada_SPITFT::getTouchscreenPoint(void) {
|
|||
return p;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Does this board have a control pad - latch, buttons or analog joystick?
|
||||
@brief Does this board have a control pad - latch, buttons or analog
|
||||
joystick?
|
||||
@returns True if it does
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
|
@ -764,7 +787,6 @@ bool Adafruit_Arcada_SPITFT::hasControlPad(void) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
@brief Convert hue, saturation and value into a packed 16-bit RGB color
|
||||
that can be passed to TFT
|
||||
|
|
@ -773,7 +795,7 @@ bool Adafruit_Arcada_SPITFT::hasControlPad(void) {
|
|||
(max or pure hue)
|
||||
@param V Value (brightness), 8-bit value, 0 (min / black / off) to
|
||||
100 (max or full brightness)
|
||||
@return Packed 16-bit 5-6-5 RGB. Result is linearly but not perceptually
|
||||
@return Packed 16-bit 5-6-5 RGB. Result is linearly but not perceptually
|
||||
correct for LEDs. Intended for TFT use only.
|
||||
*/
|
||||
// https://gist.github.com/kuathadianto/200148f53616cbd226d993b400214a7f
|
||||
|
|
@ -782,38 +804,33 @@ uint16_t Adafruit_Arcada_SPITFT::ColorHSV565(int16_t H, uint8_t S, uint8_t V) {
|
|||
double X = C * (1 - abs(fmod(H / 60.0, 2) - 1));
|
||||
double m = (V / 100.0) - C;
|
||||
double Rs, Gs, Bs;
|
||||
|
||||
if(H >= 0 && H < 60) {
|
||||
|
||||
if (H >= 0 && H < 60) {
|
||||
Rs = C;
|
||||
Gs = X;
|
||||
Bs = 0;
|
||||
}
|
||||
else if(H >= 60 && H < 120) {
|
||||
Bs = 0;
|
||||
} else if (H >= 60 && H < 120) {
|
||||
Rs = X;
|
||||
Gs = C;
|
||||
Bs = 0;
|
||||
}
|
||||
else if(H >= 120 && H < 180) {
|
||||
Bs = 0;
|
||||
} else if (H >= 120 && H < 180) {
|
||||
Rs = 0;
|
||||
Gs = C;
|
||||
Bs = X;
|
||||
}
|
||||
else if(H >= 180 && H < 240) {
|
||||
Bs = X;
|
||||
} else if (H >= 180 && H < 240) {
|
||||
Rs = 0;
|
||||
Gs = X;
|
||||
Bs = C;
|
||||
}
|
||||
else if(H >= 240 && H < 300) {
|
||||
Bs = C;
|
||||
} else if (H >= 240 && H < 300) {
|
||||
Rs = X;
|
||||
Gs = 0;
|
||||
Bs = C;
|
||||
}
|
||||
else {
|
||||
Bs = C;
|
||||
} else {
|
||||
Rs = C;
|
||||
Gs = 0;
|
||||
Bs = X;
|
||||
Bs = X;
|
||||
}
|
||||
|
||||
|
||||
uint8_t red = (Rs + m) * 255;
|
||||
uint8_t green = (Gs + m) * 255;
|
||||
uint8_t blue = (Bs + m) * 255;
|
||||
|
|
|
|||
|
|
@ -6,139 +6,143 @@
|
|||
class Adafruit_Arcada_SPITFT;
|
||||
|
||||
#include "Adafruit_Arcada_Def.h"
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <Adafruit_SPITFT.h>
|
||||
|
||||
#if defined(__SAMD21__) || defined(__SAMD51__)
|
||||
#if defined(_SAMD21_) || defined(__SAMD51__)
|
||||
#include <Adafruit_ZeroTimer.h>
|
||||
#endif
|
||||
|
||||
#include <TouchScreen.h>
|
||||
|
||||
#include "Adafruit_Arcada_PyBadge.h"
|
||||
#include "Adafruit_Arcada_PyGamer.h"
|
||||
#include "Adafruit_Arcada_PyGamerAdvance.h"
|
||||
#include "Adafruit_Arcada_PyPortal.h"
|
||||
#include "Adafruit_Arcada_MONSTERM4SK.h"
|
||||
#include "Adafruit_Arcada_HalloWingM4.h"
|
||||
#include "Adafruit_Arcada_HalloWingM0.h"
|
||||
#include "Adafruit_Arcada_CircuitPlaygroundExpress.h"
|
||||
#include "Adafruit_Arcada_CircuitPlaygroundBluefruit.h"
|
||||
#include "Boards/Adafruit_Arcada_CircuitPlaygroundBluefruit.h"
|
||||
#include "Boards/Adafruit_Arcada_CircuitPlaygroundExpress.h"
|
||||
#include "Boards/Adafruit_Arcada_Clue.h"
|
||||
#include "Boards/Adafruit_Arcada_HalloWingM0.h"
|
||||
#include "Boards/Adafruit_Arcada_HalloWingM4.h"
|
||||
#include "Boards/Adafruit_Arcada_MONSTERM4SK.h"
|
||||
#include "Boards/Adafruit_Arcada_PyBadge.h"
|
||||
#include "Boards/Adafruit_Arcada_PyGamer.h"
|
||||
#include "Boards/Adafruit_Arcada_PyGamerAdvance.h"
|
||||
#include "Boards/Adafruit_Arcada_PyPortal.h"
|
||||
#include "Boards/Adafruit_Arcada_PyPortalTitano.h"
|
||||
|
||||
#ifndef ARCADA_SD_CS
|
||||
#define ARCADA_SD_CS -1
|
||||
#ifndef ARCADA_SD_CS
|
||||
#define ARCADA_SD_CS -1
|
||||
#endif
|
||||
#ifndef ARCADA_SPEAKER_ENABLE
|
||||
#define ARCADA_SPEAKER_ENABLE -1
|
||||
#define ARCADA_SPEAKER_ENABLE -1
|
||||
#endif
|
||||
#ifndef ARCADA_NEOPIXEL_PIN
|
||||
#define ARCADA_NEOPIXEL_PIN -1
|
||||
#define ARCADA_NEOPIXEL_PIN -1
|
||||
#endif
|
||||
#ifndef ARCADA_NEOPIXEL_NUM
|
||||
#define ARCADA_NEOPIXEL_NUM 0
|
||||
#define ARCADA_NEOPIXEL_NUM 0
|
||||
#endif
|
||||
#ifndef ARCADA_TFT_LITE
|
||||
#define ARCADA_TFT_LITE -1
|
||||
#define ARCADA_TFT_LITE -1
|
||||
#endif
|
||||
#ifndef ARCADA_TFT_RST
|
||||
#define ARCADA_TFT_RST -1
|
||||
#endif
|
||||
#ifndef ARCADA_LIGHT_SENSOR
|
||||
#define ARCADA_LIGHT_SENSOR -1
|
||||
#define ARCADA_LIGHT_SENSOR -1
|
||||
#endif
|
||||
#ifndef ARCADA_BATTERY_SENSOR
|
||||
#define ARCADA_BATTERY_SENSOR -1
|
||||
#define ARCADA_BATTERY_SENSOR -1
|
||||
#endif
|
||||
|
||||
#ifndef ARCADA_JOYSTICK_X
|
||||
#define ARCADA_JOYSTICK_X -1
|
||||
#define ARCADA_JOYSTICK_X -1
|
||||
#endif
|
||||
#ifndef ARCADA_JOYSTICK_Y
|
||||
#define ARCADA_JOYSTICK_Y -1
|
||||
#define ARCADA_JOYSTICK_Y -1
|
||||
#endif
|
||||
|
||||
#ifndef ARCADA_BUTTONPIN_START
|
||||
#define ARCADA_BUTTONPIN_START -1
|
||||
#define ARCADA_BUTTONPIN_START -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_SELECT
|
||||
#define ARCADA_BUTTONPIN_SELECT -1
|
||||
#define ARCADA_BUTTONPIN_SELECT -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_A
|
||||
#define ARCADA_BUTTONPIN_A -1
|
||||
#define ARCADA_BUTTONPIN_A -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_B
|
||||
#define ARCADA_BUTTONPIN_B -1
|
||||
#define ARCADA_BUTTONPIN_B -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_UP
|
||||
#define ARCADA_BUTTONPIN_UP -1
|
||||
#define ARCADA_BUTTONPIN_UP -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_DOWN
|
||||
#define ARCADA_BUTTONPIN_DOWN -1
|
||||
#define ARCADA_BUTTONPIN_DOWN -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_RIGHT
|
||||
#define ARCADA_BUTTONPIN_RIGHT -1
|
||||
#define ARCADA_BUTTONPIN_RIGHT -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTONPIN_LEFT
|
||||
#define ARCADA_BUTTONPIN_LEFT -1
|
||||
#define ARCADA_BUTTONPIN_LEFT -1
|
||||
#endif
|
||||
|
||||
#ifndef ARCADA_BUTTON_CLOCK
|
||||
#define ARCADA_BUTTON_CLOCK -1
|
||||
#define ARCADA_BUTTON_CLOCK -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_DATA
|
||||
#define ARCADA_BUTTON_DATA -1
|
||||
#define ARCADA_BUTTON_DATA -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_LATCH
|
||||
#define ARCADA_BUTTON_LATCH -1
|
||||
#define ARCADA_BUTTON_LATCH -1
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_B
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_A
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_UP
|
||||
#define ARCADA_BUTTON_SHIFTMASK_UP 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_UP 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_DOWN
|
||||
#define ARCADA_BUTTON_SHIFTMASK_DOWN 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_DOWN 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_LEFT
|
||||
#define ARCADA_BUTTON_SHIFTMASK_LEFT 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_LEFT 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_RIGHT
|
||||
#define ARCADA_BUTTON_SHIFTMASK_RIGHT 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_RIGHT 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_START
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0
|
||||
#endif
|
||||
#ifndef ARCADA_BUTTON_SHIFTMASK_SELECT
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ARCADA_TOUCHSCREEN_XP
|
||||
#define ARCADA_TOUCHSCREEN_XP -1
|
||||
#define ARCADA_TOUCHSCREEN_XP -1
|
||||
#endif
|
||||
#ifndef ARCADA_TOUCHSCREEN_YP
|
||||
#define ARCADA_TOUCHSCREEN_YP -1
|
||||
#define ARCADA_TOUCHSCREEN_YP -1
|
||||
#endif
|
||||
#ifndef ARCADA_TOUCHSCREEN_XM
|
||||
#define ARCADA_TOUCHSCREEN_XM -1
|
||||
#define ARCADA_TOUCHSCREEN_XM -1
|
||||
#endif
|
||||
#ifndef ARCADA_TOUCHSCREEN_YM
|
||||
#define ARCADA_TOUCHSCREEN_YM -1
|
||||
#define ARCADA_TOUCHSCREEN_YM -1
|
||||
#endif
|
||||
|
||||
#ifndef ARCADA_TOUCHSCREEN_CALIBX_MIN
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MIN 0
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MIN 0
|
||||
#endif
|
||||
#ifndef ARCADA_TOUCHSCREEN_CALIBY_MIN
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MIN 0
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MIN 0
|
||||
#endif
|
||||
#ifndef ARCADA_TOUCHSCREEN_CALIBX_MAX
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MAX 1023
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MAX 1023
|
||||
#endif
|
||||
#ifndef ARCADA_TOUCHSCREEN_CALIBY_MAX
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MAX 1023
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MAX 1023
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static uint8_t maxCharPerLine, fontSize;
|
||||
static uint16_t charHeight, charWidth;
|
||||
|
||||
|
|
@ -20,37 +19,38 @@ void Adafruit_Arcada_SPITFT::_initAlertFonts(void) {
|
|||
/*!
|
||||
@brief Display an info box with optional 'press to continue' button
|
||||
@param string The message to display
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return. Default is ARCADA_BUTTONMASK_A
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return. Default is ARCADA_BUTTONMASK_A
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_Arcada_SPITFT::infoBox(const char *string, uint32_t continueButtonMask) {
|
||||
void Adafruit_Arcada_SPITFT::infoBox(const char *string,
|
||||
uint32_t continueButtonMask) {
|
||||
alertBox(string, ARCADA_WHITE, ARCADA_BLACK, continueButtonMask);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Display an warning box with optional 'press to continue' button
|
||||
@param string The message to display
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return. Default is ARCADA_BUTTONMASK_A
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return. Default is ARCADA_BUTTONMASK_A
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_Arcada_SPITFT::warnBox(const char *string, uint32_t continueButtonMask) {
|
||||
void Adafruit_Arcada_SPITFT::warnBox(const char *string,
|
||||
uint32_t continueButtonMask) {
|
||||
alertBox(string, ARCADA_YELLOW, ARCADA_WHITE, continueButtonMask);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Display an error box with optional 'press to continue' button
|
||||
@param string The message to display
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return. Default is ARCADA_BUTTONMASK_A
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return. Default is ARCADA_BUTTONMASK_A
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_Arcada_SPITFT::errorBox(const char *string, uint32_t continueButtonMask) {
|
||||
void Adafruit_Arcada_SPITFT::errorBox(const char *string,
|
||||
uint32_t continueButtonMask) {
|
||||
alertBox(string, ARCADA_RED, ARCADA_WHITE, continueButtonMask);
|
||||
}
|
||||
|
||||
|
|
@ -67,20 +67,19 @@ void Adafruit_Arcada_SPITFT::haltBox(const char *string) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Display an alert box with optional 'press to continue' button
|
||||
@param string The message to display
|
||||
@param boxColor 16-bit color to use as background
|
||||
@param textColor 16-bit color to use as outline and text
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
@param continueButtonMask ARCADA_BUTTONMASK_ value to wait for, or 0 for
|
||||
immediate return.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_Arcada_SPITFT::alertBox(const char *string, uint16_t boxColor, uint16_t textColor,
|
||||
uint32_t continueButtonMask) {
|
||||
void Adafruit_Arcada_SPITFT::alertBox(const char *string, uint16_t boxColor,
|
||||
uint16_t textColor,
|
||||
uint32_t continueButtonMask) {
|
||||
_initAlertFonts();
|
||||
|
||||
uint16_t boxWidth = (maxCharPerLine + 2) * charWidth;
|
||||
|
|
@ -89,20 +88,19 @@ void Adafruit_Arcada_SPITFT::alertBox(const char *string, uint16_t boxColor, uin
|
|||
// pre-calculate # of lines!
|
||||
uint8_t lines = 1;
|
||||
uint16_t fontX = boxX + charWidth;
|
||||
for (uint16_t c=0; c<strlen(string); c++) {
|
||||
const char *nextBreakStr = strpbrk(string+c, " \n");
|
||||
for (uint16_t c = 0; c < strlen(string); c++) {
|
||||
const char *nextBreakStr = strpbrk(string + c, " \n");
|
||||
if (!nextBreakStr) {
|
||||
nextBreakStr = string + strlen(string);
|
||||
}
|
||||
int charsToNextSpace = nextBreakStr - (string+c);
|
||||
int charsToNextSpace = nextBreakStr - (string + c);
|
||||
|
||||
if ((string[c] == '\n') ||
|
||||
((fontX+charsToNextSpace*charWidth) > (boxX + boxWidth - 2*charWidth))) {
|
||||
if ((string[c] == '\n') || ((fontX + charsToNextSpace * charWidth) >
|
||||
(boxX + boxWidth - 2 * charWidth))) {
|
||||
lines++;
|
||||
fontX = boxX + charWidth;
|
||||
}
|
||||
fontX += charWidth;
|
||||
|
||||
}
|
||||
|
||||
uint16_t boxHeight = (lines + 2) * charHeight;
|
||||
|
|
@ -117,16 +115,16 @@ void Adafruit_Arcada_SPITFT::alertBox(const char *string, uint16_t boxColor, uin
|
|||
display->setTextSize(fontSize);
|
||||
display->setTextColor(ARCADA_BLACK);
|
||||
|
||||
for (uint16_t c=0; c<strlen(string); c++) {
|
||||
const char *nextBreakStr = strpbrk(string+c, " \n");
|
||||
for (uint16_t c = 0; c < strlen(string); c++) {
|
||||
const char *nextBreakStr = strpbrk(string + c, " \n");
|
||||
if (!nextBreakStr) {
|
||||
nextBreakStr = string + strlen(string);
|
||||
}
|
||||
int charsToNextSpace = nextBreakStr - (string+c);
|
||||
//Serial.printf("%s Chars to space: %d\n", string+c, charsToNextSpace);
|
||||
int charsToNextSpace = nextBreakStr - (string + c);
|
||||
// Serial.printf("%s Chars to space: %d\n", string+c, charsToNextSpace);
|
||||
|
||||
if ((string[c] == '\n') ||
|
||||
((fontX+charsToNextSpace*charWidth) > (boxX + boxWidth - 2*charWidth))) {
|
||||
if ((string[c] == '\n') || ((fontX + charsToNextSpace * charWidth) >
|
||||
(boxX + boxWidth - 2 * charWidth))) {
|
||||
fontY += charHeight;
|
||||
fontX = boxX + charWidth;
|
||||
}
|
||||
|
|
@ -134,37 +132,37 @@ void Adafruit_Arcada_SPITFT::alertBox(const char *string, uint16_t boxColor, uin
|
|||
if (isprint(string[c]) && string[c] != '\n') {
|
||||
display->print(string[c]);
|
||||
}
|
||||
fontX += charWidth;
|
||||
if (string[c] != '\n') {
|
||||
fontX += charWidth;
|
||||
}
|
||||
}
|
||||
|
||||
if (continueButtonMask) {
|
||||
const char *buttonString = "";
|
||||
if (hasTouchscreen() && ! hasControlPad()) {
|
||||
if (hasTouchscreen() && !hasControlPad()) {
|
||||
buttonString = "TAP";
|
||||
} else {
|
||||
if (continueButtonMask == ARCADA_BUTTONMASK_A) {
|
||||
buttonString = "A";
|
||||
buttonString = "A";
|
||||
}
|
||||
if (continueButtonMask == ARCADA_BUTTONMASK_B) {
|
||||
buttonString = "B";
|
||||
buttonString = "B";
|
||||
}
|
||||
if (continueButtonMask == ARCADA_BUTTONMASK_SELECT) {
|
||||
buttonString = "Sel";
|
||||
buttonString = "Sel";
|
||||
}
|
||||
if (continueButtonMask == ARCADA_BUTTONMASK_START) {
|
||||
buttonString = "Sta";
|
||||
buttonString = "Sta";
|
||||
}
|
||||
}
|
||||
fontX = boxX + boxWidth - (strlen(buttonString)+1)*charWidth;
|
||||
fontX = boxX + boxWidth - (strlen(buttonString) + 1) * charWidth;
|
||||
fontY = boxY + boxHeight - charHeight;
|
||||
|
||||
display->fillRoundRect(fontX, fontY,
|
||||
(strlen(buttonString)+2)*charWidth, charHeight*2,
|
||||
charWidth, textColor);
|
||||
display->drawRoundRect(fontX, fontY,
|
||||
(strlen(buttonString)+2)*charWidth, charHeight*2,
|
||||
charWidth, textColor);
|
||||
display->setCursor(fontX+charWidth, fontY+charHeight/2);
|
||||
display->fillRoundRect(fontX, fontY, (strlen(buttonString) + 2) * charWidth,
|
||||
charHeight * 2, charWidth, textColor);
|
||||
display->drawRoundRect(fontX, fontY, (strlen(buttonString) + 2) * charWidth,
|
||||
charHeight * 2, charWidth, textColor);
|
||||
display->setCursor(fontX + charWidth, fontY + charHeight / 2);
|
||||
display->setTextColor(boxColor);
|
||||
display->print(buttonString);
|
||||
|
||||
|
|
@ -173,39 +171,42 @@ void Adafruit_Arcada_SPITFT::alertBox(const char *string, uint16_t boxColor, uin
|
|||
uint32_t released = justReleasedButtons();
|
||||
|
||||
if (hasTouchscreen()) {
|
||||
if (released) { // anything
|
||||
break;
|
||||
}
|
||||
if (released) { // anything
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (released & continueButtonMask) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
delay(10);
|
||||
if (released & continueButtonMask) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draws a menu and lets a user select one of the menu items
|
||||
@brief Draws a menu and lets a user select one of the menu items
|
||||
@param menu_strings List of menu-item strings
|
||||
@param menu_num Number of menu items
|
||||
@param boxColor 16-bit color to use as menu-background
|
||||
@param textColor 16-bit color to use as outline and text
|
||||
@param cancellable setting this to true will enable the user to exit the menu by pressing "B"
|
||||
@returns uint8_t, The selected menu item, returns 255 if the menu is canceled
|
||||
@param textColor 16-bit color to use as outline and text
|
||||
@param cancellable setting this to true will enable the user to exit the
|
||||
menu by pressing "B"
|
||||
@returns uint8_t, The selected menu item, returns 255 if the menu is
|
||||
canceled
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Arcada_SPITFT::menu(const char **menu_strings, uint8_t menu_num,
|
||||
uint16_t boxColor, uint16_t textColor, bool cancellable) {
|
||||
uint8_t Adafruit_Arcada_SPITFT::menu(const char **menu_strings,
|
||||
uint8_t menu_num, uint16_t boxColor,
|
||||
uint16_t textColor, bool cancellable) {
|
||||
_initAlertFonts();
|
||||
display->setTextSize(fontSize);
|
||||
|
||||
uint16_t max_len = 0;
|
||||
for (int i=0; i<menu_num; i++) {
|
||||
//Serial.printf("#%d '%s' -> %d\n", i, menu_strings[i], strlen(menu_strings[i]));
|
||||
for (int i = 0; i < menu_num; i++) {
|
||||
// Serial.printf("#%d '%s' -> %d\n", i, menu_strings[i],
|
||||
// strlen(menu_strings[i]));
|
||||
max_len = max(max_len, strlen(menu_strings[i]));
|
||||
}
|
||||
|
||||
|
|
@ -220,38 +221,38 @@ uint8_t Adafruit_Arcada_SPITFT::menu(const char **menu_strings, uint8_t menu_num
|
|||
|
||||
// Print the selection hint
|
||||
const char *buttonString = "A";
|
||||
uint16_t fontX = boxX + boxWidth - (strlen(buttonString)+1)*charWidth + 2*fontSize;
|
||||
uint16_t fontY = boxY + boxHeight - charHeight;
|
||||
display->fillRoundRect(fontX, fontY,
|
||||
(strlen(buttonString)+2)*charWidth, charHeight*2,
|
||||
charWidth, textColor);
|
||||
display->drawRoundRect(fontX, fontY,
|
||||
(strlen(buttonString)+2)*charWidth, charHeight*2,
|
||||
charWidth, boxColor);
|
||||
display->setCursor(fontX+charWidth, fontY+charHeight/2);
|
||||
uint16_t fontX =
|
||||
boxX + boxWidth - (strlen(buttonString) + 1) * charWidth + 2 * fontSize;
|
||||
uint16_t fontY = boxY + boxHeight - charHeight;
|
||||
display->fillRoundRect(fontX, fontY, (strlen(buttonString) + 2) * charWidth,
|
||||
charHeight * 2, charWidth, textColor);
|
||||
display->drawRoundRect(fontX, fontY, (strlen(buttonString) + 2) * charWidth,
|
||||
charHeight * 2, charWidth, boxColor);
|
||||
display->setCursor(fontX + charWidth, fontY + charHeight / 2);
|
||||
display->setTextColor(boxColor);
|
||||
display->print(buttonString);
|
||||
|
||||
// draw and select the menu
|
||||
int8_t selected = 0;
|
||||
fontX = boxX + charWidth/2;
|
||||
fontX = boxX + charWidth / 2;
|
||||
fontY = boxY + charHeight;
|
||||
|
||||
// wait for any buttons to be released
|
||||
while (readButtons()) delay(10);
|
||||
while (readButtons())
|
||||
delay(10);
|
||||
|
||||
while (1) {
|
||||
for (int i=0; i<menu_num; i++) {
|
||||
for (int i = 0; i < menu_num; i++) {
|
||||
if (i == selected) {
|
||||
display->setTextColor(boxColor, textColor);
|
||||
display->setTextColor(boxColor, textColor);
|
||||
} else {
|
||||
display->setTextColor(textColor, boxColor);
|
||||
display->setTextColor(textColor, boxColor);
|
||||
}
|
||||
display->setCursor(fontX, fontY+charHeight*i);
|
||||
display->setCursor(fontX, fontY + charHeight * i);
|
||||
display->print(" ");
|
||||
display->print(menu_strings[i]);
|
||||
for (int j=strlen(menu_strings[i]); j<max_len+2; j++) {
|
||||
display->print(" ");
|
||||
for (int j = strlen(menu_strings[i]); j < max_len + 2; j++) {
|
||||
display->print(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,24 +261,24 @@ uint8_t Adafruit_Arcada_SPITFT::menu(const char **menu_strings, uint8_t menu_num
|
|||
readButtons();
|
||||
uint32_t released = justReleasedButtons();
|
||||
if (released & ARCADA_BUTTONMASK_UP) {
|
||||
selected--;
|
||||
if (selected < 0)
|
||||
selected = menu_num-1;
|
||||
break;
|
||||
selected--;
|
||||
if (selected < 0)
|
||||
selected = menu_num - 1;
|
||||
break;
|
||||
}
|
||||
if (released & ARCADA_BUTTONMASK_DOWN) {
|
||||
selected++;
|
||||
if (selected > menu_num-1)
|
||||
selected = 0;
|
||||
break;
|
||||
selected++;
|
||||
if (selected > menu_num - 1)
|
||||
selected = 0;
|
||||
break;
|
||||
}
|
||||
if (released & ARCADA_BUTTONMASK_A) {
|
||||
return selected;
|
||||
return selected;
|
||||
}
|
||||
if (cancellable && (released & ARCADA_BUTTONMASK_B)) {
|
||||
return 255;
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
#if defined(ARDUINO_NRF52840_CIRCUITPLAY)
|
||||
#include <Adafruit_CircuitPlayground.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI
|
||||
#define ARCADA_TFT_CS A6 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC A7 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST -1 // Display reset done with chip
|
||||
#define ARCADA_TFT_LITE A3
|
||||
#define ARCADA_TFT_ROTATION 2
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 10
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_SPEAKER_ENABLE 11
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A8
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_CPlay_LIS3DH accel = Adafruit_CPlay_LIS3DH();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
_has_accel = true;
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
CircuitPlayground.begin();
|
||||
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
uint8_t rtna = 0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
tft->sendCommand(0xC6, &rtna, 1);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (CircuitPlayground.leftButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT;
|
||||
}
|
||||
if (CircuitPlayground.rightButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT;
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
|
||||
#include <Adafruit_CircuitPlayground.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS A6 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC A7 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST -1 // Display reset done with chip
|
||||
#define ARCADA_TFT_LITE A3
|
||||
#define ARCADA_TFT_ROTATION 2
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 10
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A8
|
||||
|
||||
#define ARCADA_SPIFLASH_CS SS
|
||||
#define ARCADA_SPIFLASH_SPI SPI
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_CPlay_LIS3DH accel = Adafruit_CPlay_LIS3DH();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
_has_accel = true;
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
CircuitPlayground.begin();
|
||||
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (CircuitPlayground.leftButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT;
|
||||
}
|
||||
if (CircuitPlayground.rightButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT;
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -4,10 +4,9 @@
|
|||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Loads the configuration JSON from the filesystem
|
||||
@brief Loads the configuration JSON from the filesystem
|
||||
(which must be initialized before this function is called) and stores
|
||||
parsed JSON data internally.
|
||||
@param filename The path to the JSON file
|
||||
|
|
@ -42,10 +41,9 @@ bool Adafruit_Arcada_SPITFT::loadConfigurationFile(const char *filename) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Saves the configuration JSON to the filesystem
|
||||
@brief Saves the configuration JSON to the filesystem
|
||||
(which must be initialized before this function is called)
|
||||
@param filename The path to the JSON file
|
||||
@return True if a the file was writable and saved
|
||||
|
|
@ -62,7 +60,7 @@ bool Adafruit_Arcada_SPITFT::saveConfigurationFile(const char *filename) {
|
|||
remove(filename);
|
||||
|
||||
// Open file for writing
|
||||
File file = open(filename, O_WRITE);
|
||||
File file = open(filename, O_WRITE | O_CREAT);
|
||||
if (!file) {
|
||||
Serial.println(F("Failed to create file"));
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
// A C-friendly header
|
||||
// A C-friendly header
|
||||
|
||||
#ifndef _ADAFRUIT_ARCADA_DEFINES
|
||||
#define _ADAFRUIT_ARCADA_DEFINES
|
||||
#define ARCADA_BUTTONMASK_A 0x01
|
||||
#define ARCADA_BUTTONMASK_B 0x02
|
||||
#define ARCADA_BUTTONMASK_SELECT 0x04
|
||||
#define ARCADA_BUTTONMASK_START 0x08
|
||||
#define ARCADA_BUTTONMASK_UP 0x10
|
||||
#define ARCADA_BUTTONMASK_DOWN 0x20
|
||||
#define ARCADA_BUTTONMASK_LEFT 0x40
|
||||
#define ARCADA_BUTTONMASK_RIGHT 0x80
|
||||
|
||||
#define ARCADA_BUTTONMASK_A 0x01
|
||||
#define ARCADA_BUTTONMASK_B 0x02
|
||||
#define ARCADA_BUTTONMASK_SELECT 0x04
|
||||
#define ARCADA_BUTTONMASK_START 0x08
|
||||
#define ARCADA_BUTTONMASK_UP 0x10
|
||||
#define ARCADA_BUTTONMASK_DOWN 0x20
|
||||
#define ARCADA_BUTTONMASK_LEFT 0x40
|
||||
#define ARCADA_BUTTONMASK_RIGHT 0x80
|
||||
|
||||
// Color definitions
|
||||
#define ARCADA_BLACK 0x0000 ///< 0, 0, 0
|
||||
#define ARCADA_NAVY 0x000F ///< 0, 0, 123
|
||||
#define ARCADA_DARKGREEN 0x03E0 ///< 0, 125, 0
|
||||
#define ARCADA_DARKCYAN 0x03EF ///< 0, 125, 123
|
||||
#define ARCADA_MAROON 0x7800 ///< 123, 0, 0
|
||||
#define ARCADA_PURPLE 0x780F ///< 123, 0, 123
|
||||
#define ARCADA_OLIVE 0x7BE0 ///< 123, 125, 0
|
||||
#define ARCADA_LIGHTGREY 0xC618 ///< 198, 195, 198
|
||||
#define ARCADA_DARKGREY 0x7BEF ///< 123, 125, 123
|
||||
#define ARCADA_BLUE 0x001F ///< 0, 0, 255
|
||||
#define ARCADA_GREEN 0x07E0 ///< 0, 255, 0
|
||||
#define ARCADA_CYAN 0x07FF ///< 0, 255, 255
|
||||
#define ARCADA_RED 0xF800 ///< 255, 0, 0
|
||||
#define ARCADA_MAGENTA 0xF81F ///< 255, 0, 255
|
||||
#define ARCADA_YELLOW 0xFFE0 ///< 255, 255, 0
|
||||
#define ARCADA_WHITE 0xFFFF ///< 255, 255, 255
|
||||
#define ARCADA_ORANGE 0xFD20 ///< 255, 165, 0
|
||||
#define ARCADA_GREENYELLOW 0xAFE5 ///< 173, 255, 41
|
||||
#define ARCADA_PINK 0xFC18 ///< 255, 130, 198
|
||||
#define ARCADA_BLACK 0x0000 ///< 0, 0, 0
|
||||
#define ARCADA_NAVY 0x000F ///< 0, 0, 123
|
||||
#define ARCADA_DARKGREEN 0x03E0 ///< 0, 125, 0
|
||||
#define ARCADA_DARKCYAN 0x03EF ///< 0, 125, 123
|
||||
#define ARCADA_MAROON 0x7800 ///< 123, 0, 0
|
||||
#define ARCADA_PURPLE 0x780F ///< 123, 0, 123
|
||||
#define ARCADA_OLIVE 0x7BE0 ///< 123, 125, 0
|
||||
#define ARCADA_LIGHTGREY 0xC618 ///< 198, 195, 198
|
||||
#define ARCADA_DARKGREY 0x7BEF ///< 123, 125, 123
|
||||
#define ARCADA_BLUE 0x001F ///< 0, 0, 255
|
||||
#define ARCADA_GREEN 0x07E0 ///< 0, 255, 0
|
||||
#define ARCADA_CYAN 0x07FF ///< 0, 255, 255
|
||||
#define ARCADA_RED 0xF800 ///< 255, 0, 0
|
||||
#define ARCADA_MAGENTA 0xF81F ///< 255, 0, 255
|
||||
#define ARCADA_YELLOW 0xFFE0 ///< 255, 255, 0
|
||||
#define ARCADA_WHITE 0xFFFF ///< 255, 255, 255
|
||||
#define ARCADA_ORANGE 0xFD20 ///< 255, 165, 0
|
||||
#define ARCADA_GREENYELLOW 0xAFE5 ///< 173, 255, 41
|
||||
#define ARCADA_PINK 0xFC18 ///< 255, 130, 198
|
||||
|
||||
|
||||
#define ARCADA_ACCEL_NONE 0x00
|
||||
#define ARCADA_ACCEL_LIS3DH 0x01
|
||||
#define ARCADA_ACCEL_MSA301 0x02
|
||||
#define ARCADA_ACCEL_NONE 0x00
|
||||
#define ARCADA_ACCEL_LIS3DH 0x01
|
||||
#define ARCADA_ACCEL_MSA301 0x02
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,26 +1,30 @@
|
|||
#include <Adafruit_Arcada_Filesystem.h>
|
||||
#include <Adafruit_Arcada.h>
|
||||
#include <Adafruit_Arcada_Filesystem.h>
|
||||
|
||||
static bool filenameValidityChecker(const char *filename, const char *extension);
|
||||
static bool filenameValidityChecker(const char *filename,
|
||||
const char *extension);
|
||||
|
||||
#if defined(ARCADA_SD_SPI_PORT)
|
||||
#if defined(ENABLE_EXTENDED_TRANSFER_CLASS)
|
||||
SdFatEX Arcada_SD_FileSys(&ARCADA_SD_SPI_PORT);
|
||||
#else
|
||||
SdFat Arcada_SD_FileSys(&ARCADA_SD_SPI_PORT);
|
||||
#endif
|
||||
#if defined(ENABLE_EXTENDED_TRANSFER_CLASS)
|
||||
SdFatEX Arcada_SD_FileSys(&ARCADA_SD_SPI_PORT);
|
||||
#else
|
||||
#if defined(ENABLE_EXTENDED_TRANSFER_CLASS)
|
||||
SdFatEX Arcada_SD_FileSys;
|
||||
#else
|
||||
SdFat Arcada_SD_FileSys;
|
||||
#endif
|
||||
SdFat Arcada_SD_FileSys(&ARCADA_SD_SPI_PORT);
|
||||
#endif
|
||||
#else
|
||||
#if defined(ENABLE_EXTENDED_TRANSFER_CLASS)
|
||||
SdFatEX Arcada_SD_FileSys;
|
||||
#else
|
||||
SdFat Arcada_SD_FileSys;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PIN_QSPI_SCK)
|
||||
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS, PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
|
||||
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
|
||||
PIN_QSPI_IO0, PIN_QSPI_IO1,
|
||||
PIN_QSPI_IO2, PIN_QSPI_IO3);
|
||||
#elif defined(ARCADA_SPIFLASH_CS)
|
||||
Adafruit_FlashTransport_SPI flashTransport(ARCADA_SPIFLASH_CS, &ARCADA_SPIFLASH_SPI);
|
||||
Adafruit_FlashTransport_SPI flashTransport(ARCADA_SPIFLASH_CS,
|
||||
&ARCADA_SPIFLASH_SPI);
|
||||
#endif
|
||||
|
||||
Adafruit_SPIFlash Arcada_QSPI_Flash(&flashTransport);
|
||||
|
|
@ -29,50 +33,55 @@ FatFileSystem Arcada_QSPI_FileSys;
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialize the filesystem, either SD or QSPI
|
||||
@param desiredFilesys The filesystem we'd prefer to use, can be ARCADA_FILESYS_SD, ARCADA_FILESYS_QSPI, or ARCADA_FILESYS_SD_AND_QSPI
|
||||
@return Filesystem type found, can be ARCADA_FILESYS_NONE (none found), ARCADA_FILESYS_SD (found SD card), ARCADA_FILESYS_QSPI (QSPI flash memory), or ARCADA_FILESYS_SD_AND_QSPI (both found)
|
||||
@param desiredFilesys The filesystem we'd prefer to use, can be
|
||||
ARCADA_FILESYS_SD, ARCADA_FILESYS_QSPI, or ARCADA_FILESYS_SD_AND_QSPI
|
||||
@return Filesystem type found, can be ARCADA_FILESYS_NONE (none found),
|
||||
ARCADA_FILESYS_SD (found SD card), ARCADA_FILESYS_QSPI (QSPI flash memory),
|
||||
or ARCADA_FILESYS_SD_AND_QSPI (both found)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Arcada_FilesystemType Adafruit_Arcada_SPITFT::filesysBegin(Arcada_FilesystemType desiredFilesys) {
|
||||
Arcada_FilesystemType
|
||||
Adafruit_Arcada_SPITFT::filesysBegin(Arcada_FilesystemType desiredFilesys) {
|
||||
if (_filesys_type != ARCADA_FILESYS_NONE) {
|
||||
return _filesys_type;
|
||||
}
|
||||
|
||||
if (ARCADA_SD_CS >= 0) {
|
||||
if (desiredFilesys == ARCADA_FILESYS_SD ||
|
||||
desiredFilesys == ARCADA_FILESYS_SD_AND_QSPI) {
|
||||
if (desiredFilesys == ARCADA_FILESYS_SD ||
|
||||
desiredFilesys == ARCADA_FILESYS_SD_AND_QSPI) {
|
||||
Serial.println("Trying SD Card filesystem");
|
||||
if (Arcada_SD_FileSys.begin(ARCADA_SD_CS)) {
|
||||
Serial.println("SD card found");
|
||||
SD_imagereader = new Adafruit_ImageReader(Arcada_SD_FileSys);
|
||||
_filesys_type = ARCADA_FILESYS_SD;
|
||||
Serial.println("SD card found");
|
||||
SD_imagereader = new Adafruit_ImageReader(Arcada_SD_FileSys);
|
||||
_filesys_type = ARCADA_FILESYS_SD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_filesys_type == desiredFilesys) {
|
||||
// we wanted SD, and we got it!
|
||||
return _filesys_type;
|
||||
}
|
||||
}
|
||||
|
||||
if (desiredFilesys == ARCADA_FILESYS_QSPI ||
|
||||
if (desiredFilesys == ARCADA_FILESYS_QSPI ||
|
||||
desiredFilesys == ARCADA_FILESYS_SD_AND_QSPI) {
|
||||
if (Arcada_QSPI_Flash.begin()) {
|
||||
Serial.println("QSPI filesystem found");
|
||||
Serial.print("QSPI flash chip JEDEC ID: 0x");
|
||||
Serial.print("QSPI flash chip JEDEC ID: 0x");
|
||||
Serial.println(Arcada_QSPI_Flash.getJEDECID(), HEX);
|
||||
|
||||
|
||||
// First call begin to mount the filesystem. Check that it returns true
|
||||
// to make sure the filesystem was mounted.
|
||||
if (!Arcada_QSPI_FileSys.begin(&Arcada_QSPI_Flash)) {
|
||||
Serial.println("Failed to mount filesystem!");
|
||||
Serial.println("Was CircuitPython loaded on the board first to create the filesystem?");
|
||||
return _filesys_type;
|
||||
Serial.println("Failed to mount filesystem!");
|
||||
Serial.println("Was CircuitPython loaded on the board first to create "
|
||||
"the filesystem?");
|
||||
return _filesys_type;
|
||||
}
|
||||
if (_filesys_type == ARCADA_FILESYS_SD) {
|
||||
_filesys_type = ARCADA_FILESYS_SD_AND_QSPI;
|
||||
_filesys_type = ARCADA_FILESYS_SD_AND_QSPI;
|
||||
} else {
|
||||
_filesys_type = ARCADA_FILESYS_QSPI;
|
||||
_filesys_type = ARCADA_FILESYS_QSPI;
|
||||
}
|
||||
QSPI_imagereader = new Adafruit_ImageReader(Arcada_QSPI_FileSys);
|
||||
}
|
||||
|
|
@ -84,7 +93,8 @@ Arcada_FilesystemType Adafruit_Arcada_SPITFT::filesysBegin(Arcada_FilesystemType
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set working filesys directory to a given path (makes file naming easier)
|
||||
@brief Set working filesys directory to a given path (makes file naming
|
||||
easier)
|
||||
@param path A string with the directory to change to
|
||||
@return True if was able to find a directory at that path
|
||||
*/
|
||||
|
|
@ -92,11 +102,11 @@ Arcada_FilesystemType Adafruit_Arcada_SPITFT::filesysBegin(Arcada_FilesystemType
|
|||
bool Adafruit_Arcada_SPITFT::chdir(const char *path) {
|
||||
Serial.printf("\tArcadaFileSys : chdir '%s'\n", path);
|
||||
|
||||
if (strlen(path) >= sizeof(_cwd_path)) { // too long!
|
||||
if (strlen(path) >= sizeof(_cwd_path)) { // too long!
|
||||
return false;
|
||||
}
|
||||
strcpy(_cwd_path, path);
|
||||
|
||||
|
||||
File dir;
|
||||
if (_filesys_type == ARCADA_FILESYS_NONE) {
|
||||
return false;
|
||||
|
|
@ -106,14 +116,14 @@ bool Adafruit_Arcada_SPITFT::chdir(const char *path) {
|
|||
(_filesys_type == ARCADA_FILESYS_SD_AND_QSPI)) {
|
||||
dir = Arcada_SD_FileSys.open(_cwd_path);
|
||||
} else if ((_filesys_type == ARCADA_FILESYS_QSPI) ||
|
||||
(!dir && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
(!dir && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
dir = Arcada_QSPI_FileSys.open(_cwd_path);
|
||||
}
|
||||
if (! dir) { // couldnt open?
|
||||
if (!dir) { // couldnt open?
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! dir.isDirectory()) { // not a directory or something else :(
|
||||
if (!dir.isDirectory()) { // not a directory or something else :(
|
||||
return false;
|
||||
}
|
||||
// ok could open and is dir
|
||||
|
|
@ -121,18 +131,19 @@ bool Adafruit_Arcada_SPITFT::chdir(const char *path) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Debugging helper, prints to Serial a list of files in a path
|
||||
@param path A string with the filename path, must start with / e.g. "/roms".
|
||||
If nothing is passed in, we use the CWD (default is "/")
|
||||
@param extensionFilter The 3 letters to check at the end of the filename to match
|
||||
@param path A string with the filename path, must start with / e.g.
|
||||
"/roms". If nothing is passed in, we use the CWD (default is "/")
|
||||
@param extensionFilter The 3 letters to check at the end of the filename to
|
||||
match
|
||||
@return -1 if was not able to open, or the number of files
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int16_t Adafruit_Arcada_SPITFT::filesysListFiles(const char *path, const char *extensionFilter) {
|
||||
if (! path) { // use CWD!
|
||||
int16_t Adafruit_Arcada_SPITFT::filesysListFiles(const char *path,
|
||||
const char *extensionFilter) {
|
||||
if (!path) { // use CWD!
|
||||
path = _cwd_path;
|
||||
}
|
||||
|
||||
|
|
@ -148,28 +159,29 @@ int16_t Adafruit_Arcada_SPITFT::filesysListFiles(const char *path, const char *e
|
|||
(_filesys_type == ARCADA_FILESYS_SD_AND_QSPI)) {
|
||||
dir = Arcada_SD_FileSys.open(_cwd_path);
|
||||
} else if ((_filesys_type == ARCADA_FILESYS_QSPI) ||
|
||||
(!dir && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
(!dir && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
dir = Arcada_QSPI_FileSys.open(_cwd_path);
|
||||
}
|
||||
|
||||
if (!dir)
|
||||
if (!dir)
|
||||
return -1;
|
||||
|
||||
while (1) {
|
||||
File entry = dir.openNextFile();
|
||||
if (! entry) {
|
||||
File entry = dir.openNextFile();
|
||||
if (!entry) {
|
||||
return num_files; // no more files
|
||||
}
|
||||
entry.getName(filename, SD_MAX_FILENAME_SIZE);
|
||||
if (entry.isDirectory() || filenameValidityChecker(filename, extensionFilter)) {
|
||||
if (entry.isDirectory() ||
|
||||
filenameValidityChecker(filename, extensionFilter)) {
|
||||
Serial.print(filename);
|
||||
if (entry.isDirectory()) {
|
||||
Serial.println("/");
|
||||
Serial.println("/");
|
||||
} else {
|
||||
num_files++;
|
||||
// files have sizes, directories do not
|
||||
Serial.print("\t\t");
|
||||
Serial.println(entry.size(), DEC);
|
||||
num_files++;
|
||||
// files have sizes, directories do not
|
||||
Serial.print("\t\t");
|
||||
Serial.println(entry.size(), DEC);
|
||||
}
|
||||
}
|
||||
entry.close();
|
||||
|
|
@ -177,7 +189,6 @@ int16_t Adafruit_Arcada_SPITFT::filesysListFiles(const char *path, const char *e
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Tests if a file exists on the filesys
|
||||
|
|
@ -188,12 +199,12 @@ int16_t Adafruit_Arcada_SPITFT::filesysListFiles(const char *path, const char *e
|
|||
bool Adafruit_Arcada_SPITFT::exists(const char *path) {
|
||||
Serial.printf("\tArcadaFileSys : Exists? '%s'\n", path);
|
||||
File f = open(path);
|
||||
if (!f) return false;
|
||||
if (!f)
|
||||
return false;
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Make a directory in the filesys
|
||||
|
|
@ -210,14 +221,13 @@ bool Adafruit_Arcada_SPITFT::mkdir(const char *path) {
|
|||
(_filesys_type == ARCADA_FILESYS_SD_AND_QSPI)) {
|
||||
ret = Arcada_SD_FileSys.mkdir(path);
|
||||
} else if ((_filesys_type == ARCADA_FILESYS_QSPI) ||
|
||||
(!ret && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
(!ret && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
ret = Arcada_QSPI_FileSys.mkdir(path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Remove a file from the filesys
|
||||
|
|
@ -234,26 +244,26 @@ bool Adafruit_Arcada_SPITFT::remove(const char *path) {
|
|||
(_filesys_type == ARCADA_FILESYS_SD_AND_QSPI)) {
|
||||
ret = Arcada_SD_FileSys.remove(path);
|
||||
} else if ((_filesys_type == ARCADA_FILESYS_QSPI) ||
|
||||
(!ret && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
(!ret && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
ret = Arcada_QSPI_FileSys.remove(path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Opens a file and returns the object, a wrapper for our filesystem
|
||||
@param path A string with the filename path, must start with / e.g. "/roms"
|
||||
@param flags Defaults to O_READ but can use O_WRITE for writing (uses SDfat's flag system)
|
||||
@param flags Defaults to O_READ but can use O_WRITE for writing (uses
|
||||
SDfat's flag system)
|
||||
@return A File object, for whatever filesystem we're using
|
||||
*/
|
||||
/**************************************************************************/
|
||||
File Adafruit_Arcada_SPITFT::open(const char *path, uint32_t flags) {
|
||||
const char *the_path;
|
||||
|
||||
if (!path) { // Just the CWD then
|
||||
if (!path) { // Just the CWD then
|
||||
Serial.printf("\tArcadaFileSys : open no path '%s'\n", _cwd_path);
|
||||
the_path = _cwd_path;
|
||||
} else if (path[0] == '/') { // absolute path
|
||||
|
|
@ -276,28 +286,35 @@ File Adafruit_Arcada_SPITFT::open(const char *path, uint32_t flags) {
|
|||
(_filesys_type == ARCADA_FILESYS_SD_AND_QSPI)) {
|
||||
f = Arcada_SD_FileSys.open(the_path, flags);
|
||||
} else if ((_filesys_type == ARCADA_FILESYS_QSPI) ||
|
||||
(!f && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
(!f && (_filesys_type == ARCADA_FILESYS_SD_AND_QSPI))) {
|
||||
f = Arcada_QSPI_FileSys.open(the_path, flags);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Opens a file as an indexed # in a directory (0 is first file), and returns the object
|
||||
@param path A string with the directory path, must start with / e.g. "/roms"
|
||||
@brief Opens a file as an indexed # in a directory (0 is first file), and
|
||||
returns the object
|
||||
@param path A string with the directory path, must start with / e.g.
|
||||
"/roms"
|
||||
@param index The n'th file to open, 0 is first file
|
||||
@param flags Defaults to O_READ but can use O_WRITE for writing (uses SDfat's flag system)
|
||||
@param extensionFilter A 3 (or more?) string to match against the final characters of each file for them to count. If they don't match, the index isn't incremented at all. We toupper() the extension and filename so don't worry about it.
|
||||
@param flags Defaults to O_READ but can use O_WRITE for writing (uses
|
||||
SDfat's flag system)
|
||||
@param extensionFilter A 3 (or more?) string to match against the final
|
||||
characters of each file for them to count. If they don't match, the index
|
||||
isn't incremented at all. We toupper() the extension and filename so don't
|
||||
worry about it.
|
||||
@return A File object, for whatever filesystem we're using
|
||||
*/
|
||||
/**************************************************************************/
|
||||
File Adafruit_Arcada_SPITFT::openFileByIndex(const char *path, uint16_t index,
|
||||
uint32_t flags, const char *extensionFilter) {
|
||||
if (! path) { // use CWD!
|
||||
File Adafruit_Arcada_SPITFT::openFileByIndex(const char *path, uint16_t index,
|
||||
uint32_t flags,
|
||||
const char *extensionFilter) {
|
||||
(void)flags;
|
||||
|
||||
if (!path) { // use CWD!
|
||||
path = _cwd_path;
|
||||
}
|
||||
|
||||
|
|
@ -306,19 +323,20 @@ File Adafruit_Arcada_SPITFT::openFileByIndex(const char *path, uint16_t index,
|
|||
uint16_t file_number = 0;
|
||||
File tmpFile;
|
||||
|
||||
if (!dir)
|
||||
if (!dir)
|
||||
return tmpFile;
|
||||
|
||||
while (1) {
|
||||
tmpFile = dir.openNextFile();
|
||||
if (! tmpFile) {
|
||||
tmpFile = dir.openNextFile();
|
||||
if (!tmpFile) {
|
||||
return tmpFile;
|
||||
}
|
||||
tmpFile.getName(filename, SD_MAX_FILENAME_SIZE);
|
||||
|
||||
if (!tmpFile.isDirectory() && filenameValidityChecker(filename, extensionFilter)) {
|
||||
if (!tmpFile.isDirectory() &&
|
||||
filenameValidityChecker(filename, extensionFilter)) {
|
||||
if (file_number == index) {
|
||||
return tmpFile;
|
||||
return tmpFile;
|
||||
}
|
||||
file_number++;
|
||||
}
|
||||
|
|
@ -330,28 +348,34 @@ File Adafruit_Arcada_SPITFT::openFileByIndex(const char *path, uint16_t index,
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Presents a navigation menu for choosing a file from the filesys
|
||||
@param path A string with the starting directory path, must start with / e.g. "/roms"
|
||||
@param selected_filename A buffer to put the final selection in.
|
||||
@param path A string with the starting directory path, must start with /
|
||||
e.g. "/roms"
|
||||
@param selected_filename A buffer to put the final selection in.
|
||||
Given long filename support, make this big!
|
||||
@param selected_filename_maxlen Maximum buffer available in 'selected_filename'
|
||||
@param extensionFilter A 3 (or more?) string to match against the final characters
|
||||
of each file for them to count. If they don't match, the index isn't incremented at
|
||||
all. We toupper() the extension and filename so don't worry about it.
|
||||
@param selected_filename_maxlen Maximum buffer available in
|
||||
'selected_filename'
|
||||
@param extensionFilter A 3 (or more?) string to match against the final
|
||||
characters of each file for them to count. If they don't match, the index
|
||||
isn't incremented at all. We toupper() the extension and filename so don't
|
||||
worry about it.
|
||||
@return true on success, false on some sort of failure
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::chooseFile(const char *path,
|
||||
char *selected_filename, uint16_t selected_filename_maxlen,
|
||||
const char *extensionFilter) {
|
||||
int8_t selected_line = 0; // the line # that we have selected
|
||||
bool selected_isdir = false; // whether the current line is a directory
|
||||
int8_t selected_scroll_idx = 0; // where to start drawing for selected filename scroll
|
||||
int starting_line = 0; // what line to start drawing at (for scrolling thru files)
|
||||
char curr_path[255]; // The current working directory
|
||||
File entry; // iterate thru directory entries
|
||||
uint32_t repeatTimestamp = millis(); // a timestamp for repeat presses
|
||||
char *selected_filename,
|
||||
uint16_t selected_filename_maxlen,
|
||||
const char *extensionFilter) {
|
||||
int8_t selected_line = 0; // the line # that we have selected
|
||||
bool selected_isdir = false; // whether the current line is a directory
|
||||
int8_t selected_scroll_idx =
|
||||
0; // where to start drawing for selected filename scroll
|
||||
int starting_line =
|
||||
0; // what line to start drawing at (for scrolling thru files)
|
||||
char curr_path[255]; // The current working directory
|
||||
File entry; // iterate thru directory entries
|
||||
uint32_t repeatTimestamp = millis(); // a timestamp for repeat presses
|
||||
|
||||
if (! path) { // use CWD!
|
||||
if (!path) { // use CWD!
|
||||
path = _cwd_path;
|
||||
}
|
||||
|
||||
|
|
@ -361,86 +385,93 @@ bool Adafruit_Arcada_SPITFT::chooseFile(const char *path,
|
|||
display->setTextWrap(false);
|
||||
|
||||
bool redraw = true; // we need to redraw the filenames/selection
|
||||
bool chdir = true; // changed dir, we need to redraw everything!
|
||||
int line = 0;
|
||||
bool chdir = true; // changed dir, we need to redraw everything!
|
||||
int line = 0;
|
||||
while (1) {
|
||||
delay(10);
|
||||
if (redraw || chdir) {
|
||||
File dir = open(curr_path);
|
||||
if (!dir) {
|
||||
Serial.println("Not a directory!");
|
||||
return false;
|
||||
Serial.println("Not a directory!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (chdir) {
|
||||
Serial.println("\nRedrawing menu");
|
||||
starting_line = selected_line = 0;
|
||||
display->fillScreen(ARCADA_BLACK);
|
||||
display->fillRect(0, 0, ARCADA_TFT_WIDTH, FILECHOOSEMENU_TEXT_HEIGHT*2, ARCADA_BLUE);
|
||||
display->setTextColor(ARCADA_WHITE);
|
||||
|
||||
// figure out how to display the directory at the top
|
||||
int dirlen = strlen(curr_path);
|
||||
if (dirlen != 1) dirlen++; // if not '/'
|
||||
if (extensionFilter) dirlen += 2+strlen(extensionFilter); // if we'll be displaying *.txt
|
||||
display->setCursor((ARCADA_TFT_WIDTH - dirlen*FILECHOOSEMENU_TEXT_WIDTH)/2, 0);
|
||||
display->print(curr_path);
|
||||
if (strcmp(curr_path, "/") != 0) {
|
||||
display->print("/");
|
||||
}
|
||||
if (extensionFilter) {
|
||||
display->print("*.");
|
||||
display->print(extensionFilter);
|
||||
}
|
||||
display->setCursor(0, FILECHOOSEMENU_TEXT_HEIGHT);
|
||||
display->print("A to select & B to go back");
|
||||
chdir = false;
|
||||
Serial.println("\nRedrawing menu");
|
||||
starting_line = selected_line = 0;
|
||||
display->fillScreen(ARCADA_BLACK);
|
||||
display->fillRect(0, 0, ARCADA_TFT_WIDTH,
|
||||
FILECHOOSEMENU_TEXT_HEIGHT * 2, ARCADA_BLUE);
|
||||
display->setTextColor(ARCADA_WHITE);
|
||||
|
||||
// figure out how to display the directory at the top
|
||||
int dirlen = strlen(curr_path);
|
||||
if (dirlen != 1)
|
||||
dirlen++; // if not '/'
|
||||
if (extensionFilter)
|
||||
dirlen += 2 + strlen(extensionFilter); // if we'll be displaying *.txt
|
||||
display->setCursor(
|
||||
(ARCADA_TFT_WIDTH - dirlen * FILECHOOSEMENU_TEXT_WIDTH) / 2, 0);
|
||||
display->print(curr_path);
|
||||
if (strcmp(curr_path, "/") != 0) {
|
||||
display->print("/");
|
||||
}
|
||||
if (extensionFilter) {
|
||||
display->print("*.");
|
||||
display->print(extensionFilter);
|
||||
}
|
||||
display->setCursor(0, FILECHOOSEMENU_TEXT_HEIGHT);
|
||||
display->print("A to select & B to go back");
|
||||
chdir = false;
|
||||
}
|
||||
|
||||
display->setCursor(0, FILECHOOSEMENU_TEXT_HEIGHT*2);
|
||||
display->setCursor(0, FILECHOOSEMENU_TEXT_HEIGHT * 2);
|
||||
line = 0;
|
||||
while (entry = dir.openNextFile()) {
|
||||
char filename[SD_MAX_FILENAME_SIZE];
|
||||
filename[0] = 0;
|
||||
entry.getName(filename, SD_MAX_FILENAME_SIZE-1);
|
||||
char filename[SD_MAX_FILENAME_SIZE];
|
||||
filename[0] = 0;
|
||||
entry.getName(filename, SD_MAX_FILENAME_SIZE - 1);
|
||||
|
||||
if (entry.isDirectory() || filenameValidityChecker(filename, extensionFilter)) {
|
||||
if (line == selected_line) {
|
||||
display->setTextColor(ARCADA_YELLOW, ARCADA_RED);
|
||||
int maxlen = selected_filename_maxlen-1;
|
||||
char *fn_ptr = selected_filename;
|
||||
strncpy(fn_ptr, curr_path, maxlen);
|
||||
maxlen -= strlen(curr_path);
|
||||
fn_ptr += strlen(fn_ptr);
|
||||
// add a '/' if there isnt one already
|
||||
if (fn_ptr[-1] != '/') {
|
||||
strncpy(fn_ptr, "/", maxlen);
|
||||
maxlen -= 1;
|
||||
fn_ptr++;
|
||||
}
|
||||
strncpy(fn_ptr, filename, maxlen);
|
||||
fn_ptr += strlen(filename);
|
||||
maxlen -= strlen(filename);
|
||||
if (entry.isDirectory() ||
|
||||
filenameValidityChecker(filename, extensionFilter)) {
|
||||
if (line == selected_line) {
|
||||
display->setTextColor(ARCADA_YELLOW, ARCADA_RED);
|
||||
int maxlen = selected_filename_maxlen - 1;
|
||||
char *fn_ptr = selected_filename;
|
||||
strncpy(fn_ptr, curr_path, maxlen);
|
||||
maxlen -= strlen(curr_path);
|
||||
fn_ptr += strlen(fn_ptr);
|
||||
// add a '/' if there isnt one already
|
||||
if (fn_ptr[-1] != '/') {
|
||||
strncpy(fn_ptr, "/", maxlen);
|
||||
maxlen -= 1;
|
||||
fn_ptr++;
|
||||
}
|
||||
strncpy(fn_ptr, filename, maxlen);
|
||||
fn_ptr += strlen(filename);
|
||||
maxlen -= strlen(filename);
|
||||
|
||||
Serial.print("Select -> "); Serial.println(selected_filename);
|
||||
selected_isdir = entry.isDirectory();
|
||||
} else {
|
||||
display->setTextColor(ARCADA_WHITE, ARCADA_BLACK);
|
||||
}
|
||||
//Serial.printf("line %d, starting %d\n", line, starting_line);
|
||||
if (line >= starting_line) {
|
||||
display->print(filename);
|
||||
if (entry.isDirectory()) {
|
||||
display->print("/");
|
||||
}
|
||||
for (int x=strlen(filename); x<FILECHOOSEMENU_MAX_LINELENGTH+1; x++) {
|
||||
display->print(" ");
|
||||
}
|
||||
display->println();
|
||||
}
|
||||
line++;
|
||||
}
|
||||
entry.close();
|
||||
Serial.print("Select -> ");
|
||||
Serial.println(selected_filename);
|
||||
selected_isdir = entry.isDirectory();
|
||||
} else {
|
||||
display->setTextColor(ARCADA_WHITE, ARCADA_BLACK);
|
||||
}
|
||||
// Serial.printf("line %d, starting %d\n", line, starting_line);
|
||||
if (line >= starting_line) {
|
||||
display->print(filename);
|
||||
if (entry.isDirectory()) {
|
||||
display->print("/");
|
||||
}
|
||||
for (int x = strlen(filename);
|
||||
x < FILECHOOSEMENU_MAX_LINELENGTH + 1; x++) {
|
||||
display->print(" ");
|
||||
}
|
||||
display->println();
|
||||
}
|
||||
line++;
|
||||
}
|
||||
entry.close();
|
||||
}
|
||||
dir.close();
|
||||
redraw = false;
|
||||
|
|
@ -454,84 +485,88 @@ bool Adafruit_Arcada_SPITFT::chooseFile(const char *path,
|
|||
|
||||
// Fake a repeating press for scrolling thru a filelist fast!
|
||||
if (currPressed & ARCADA_BUTTONMASK_UP) {
|
||||
justPressed |= ARCADA_BUTTONMASK_UP;
|
||||
justPressed |= ARCADA_BUTTONMASK_UP;
|
||||
}
|
||||
if (currPressed & ARCADA_BUTTONMASK_DOWN) {
|
||||
justPressed |= ARCADA_BUTTONMASK_DOWN;
|
||||
justPressed |= ARCADA_BUTTONMASK_DOWN;
|
||||
}
|
||||
|
||||
// Scroll the selected filename?
|
||||
char *fn_ptr = selected_filename;
|
||||
fn_ptr = strrchr(selected_filename, '/');
|
||||
if (fn_ptr) {
|
||||
fn_ptr++;
|
||||
int scrollnum = strlen(fn_ptr) - FILECHOOSEMENU_MAX_LINELENGTH;
|
||||
if (scrollnum > 0) {
|
||||
int ypos = ((selected_line - starting_line) + 2) * FILECHOOSEMENU_TEXT_HEIGHT;
|
||||
display->setTextColor(ARCADA_YELLOW, ARCADA_RED);
|
||||
display->setCursor(0, ypos);
|
||||
display->print(fn_ptr+selected_scroll_idx);
|
||||
for (int s=strlen(fn_ptr+selected_scroll_idx); s<FILECHOOSEMENU_MAX_LINELENGTH+2; s++) {
|
||||
display->print(' ');
|
||||
}
|
||||
selected_scroll_idx++;
|
||||
if (selected_scroll_idx > scrollnum) {
|
||||
selected_scroll_idx = 0;
|
||||
}
|
||||
}
|
||||
fn_ptr++;
|
||||
int scrollnum = strlen(fn_ptr) - FILECHOOSEMENU_MAX_LINELENGTH;
|
||||
if (scrollnum > 0) {
|
||||
int ypos = ((selected_line - starting_line) + 2) *
|
||||
FILECHOOSEMENU_TEXT_HEIGHT;
|
||||
display->setTextColor(ARCADA_YELLOW, ARCADA_RED);
|
||||
display->setCursor(0, ypos);
|
||||
display->print(fn_ptr + selected_scroll_idx);
|
||||
for (int s = strlen(fn_ptr + selected_scroll_idx);
|
||||
s < FILECHOOSEMENU_MAX_LINELENGTH + 2; s++) {
|
||||
display->print(' ');
|
||||
}
|
||||
selected_scroll_idx++;
|
||||
if (selected_scroll_idx > scrollnum) {
|
||||
selected_scroll_idx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for selection or movement
|
||||
if (justPressed) {
|
||||
repeatTimestamp = millis();
|
||||
if (justPressed & ARCADA_BUTTONMASK_DOWN) {
|
||||
selected_line++;
|
||||
if (selected_line >= line) {
|
||||
selected_line = 0;
|
||||
starting_line = 0;
|
||||
}
|
||||
if (selected_line >= FILECHOOSEMENU_MAX_LINES) {
|
||||
starting_line = selected_line - FILECHOOSEMENU_MAX_LINES + 1;
|
||||
}
|
||||
redraw = true;
|
||||
}
|
||||
else if (justPressed & ARCADA_BUTTONMASK_UP) {
|
||||
selected_line--;
|
||||
if (selected_line < 0) {
|
||||
selected_line = line-1;
|
||||
}
|
||||
if (selected_line >= FILECHOOSEMENU_MAX_LINES) {
|
||||
starting_line = selected_line - FILECHOOSEMENU_MAX_LINES + 1;
|
||||
}
|
||||
if (selected_line < starting_line) {
|
||||
starting_line = selected_line;
|
||||
}
|
||||
redraw = true;
|
||||
}
|
||||
else if (justPressed & ARCADA_BUTTONMASK_A) {
|
||||
if (!selected_isdir) {
|
||||
break;
|
||||
}
|
||||
// change dir
|
||||
Serial.print("Chdir from "); Serial.print(curr_path);
|
||||
strncpy(curr_path, selected_filename, 255);
|
||||
Serial.print(" to "); Serial.println(curr_path);
|
||||
chdir = true;
|
||||
}
|
||||
else if (justPressed & ARCADA_BUTTONMASK_B) {
|
||||
if (strcmp(curr_path, "/") != 0) {
|
||||
// get rid of trailing /
|
||||
if (curr_path[strlen(curr_path)-1] == '/') {
|
||||
curr_path[strlen(curr_path)-1] = 0;
|
||||
}
|
||||
Serial.print("Chdir from "); Serial.print(curr_path);
|
||||
char *last = strrchr(curr_path, '/');
|
||||
if (last) {
|
||||
last[1] = 0; // ok slice off at this point!
|
||||
}
|
||||
Serial.print(" to "); Serial.println(curr_path);
|
||||
chdir = true;
|
||||
}
|
||||
selected_line++;
|
||||
if (selected_line >= line) {
|
||||
selected_line = 0;
|
||||
starting_line = 0;
|
||||
}
|
||||
if (selected_line >= FILECHOOSEMENU_MAX_LINES) {
|
||||
starting_line = selected_line - FILECHOOSEMENU_MAX_LINES + 1;
|
||||
}
|
||||
redraw = true;
|
||||
} else if (justPressed & ARCADA_BUTTONMASK_UP) {
|
||||
selected_line--;
|
||||
if (selected_line < 0) {
|
||||
selected_line = line - 1;
|
||||
}
|
||||
if (selected_line >= FILECHOOSEMENU_MAX_LINES) {
|
||||
starting_line = selected_line - FILECHOOSEMENU_MAX_LINES + 1;
|
||||
}
|
||||
if (selected_line < starting_line) {
|
||||
starting_line = selected_line;
|
||||
}
|
||||
redraw = true;
|
||||
} else if (justPressed & ARCADA_BUTTONMASK_A) {
|
||||
if (!selected_isdir) {
|
||||
break;
|
||||
}
|
||||
// change dir
|
||||
Serial.print("Chdir from ");
|
||||
Serial.print(curr_path);
|
||||
strncpy(curr_path, selected_filename, 255);
|
||||
Serial.print(" to ");
|
||||
Serial.println(curr_path);
|
||||
chdir = true;
|
||||
} else if (justPressed & ARCADA_BUTTONMASK_B) {
|
||||
if (strcmp(curr_path, "/") != 0) {
|
||||
// get rid of trailing /
|
||||
if (curr_path[strlen(curr_path) - 1] == '/') {
|
||||
curr_path[strlen(curr_path) - 1] = 0;
|
||||
}
|
||||
Serial.print("Chdir from ");
|
||||
Serial.print(curr_path);
|
||||
char *last = strrchr(curr_path, '/');
|
||||
if (last) {
|
||||
last[1] = 0; // ok slice off at this point!
|
||||
}
|
||||
Serial.print(" to ");
|
||||
Serial.println(curr_path);
|
||||
chdir = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -540,19 +575,20 @@ bool Adafruit_Arcada_SPITFT::chooseFile(const char *path,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool filenameValidityChecker(const char *filename, const char *extensionFilter) {
|
||||
static bool filenameValidityChecker(const char *filename,
|
||||
const char *extensionFilter) {
|
||||
if (strlen(filename) > 2) {
|
||||
if ((filename[0] == '.') && (filename[1] == '_')) {
|
||||
return false; // annoying macOS trashfiles
|
||||
return false; // annoying macOS trashfiles
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check the last 3 (or 4?) characters to see if its the right filetype
|
||||
if (extensionFilter) {
|
||||
const char *p = filename + strlen(filename) - strlen(extensionFilter);
|
||||
for (uint16_t i=0; i<strlen(extensionFilter); i++) {
|
||||
for (uint16_t i = 0; i < strlen(extensionFilter); i++) {
|
||||
if (toupper(p[i]) != toupper(extensionFilter[i])) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
#if ARCADA_TFT_WIDTH > 200
|
||||
#define FILECHOOSEMENU_TEXT_SIZE 2
|
||||
#define FILECHOOSEMENU_TEXT_SIZE 2
|
||||
#else
|
||||
#define FILECHOOSEMENU_TEXT_SIZE 1
|
||||
#define FILECHOOSEMENU_TEXT_SIZE 1
|
||||
#endif
|
||||
|
||||
#define FILECHOOSEMENU_TEXT_HEIGHT (FILECHOOSEMENU_TEXT_SIZE*8)
|
||||
#define FILECHOOSEMENU_TEXT_WIDTH (FILECHOOSEMENU_TEXT_SIZE*6)
|
||||
#define FILECHOOSEMENU_MAX_FILENAME_SIZE 80
|
||||
#define FILECHOOSEMENU_MAX_LINELENGTH (ARCADA_TFT_WIDTH / FILECHOOSEMENU_TEXT_WIDTH)
|
||||
#define FILECHOOSEMENU_MAX_LINES ((ARCADA_TFT_HEIGHT / FILECHOOSEMENU_TEXT_HEIGHT) - 2)
|
||||
#define FILECHOOSEMENU_FILE_XOFFSET (FILECHOOSEMENU_TEXT_WIDTH/2)
|
||||
#define FILECHOOSEMENU_FILE_YOFFSET (2*FILECHOOSEMENU_TEXT_HEIGHT)
|
||||
#define FILECHOOSEMENU_FILE_W ARCADA_TFT_WIDTH
|
||||
#define FILECHOOSEMENU_FILE_H (FILECHOOSEMENU_MAX_LINES*FILECHOOSEMENU_TEXT_HEIGHT)
|
||||
#define FILECHOOSEMENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define FILECHOOSEMENU_JOYS_YOFFSET (12*FILECHOOSEMENU_TEXT_HEIGHT)
|
||||
#define FILECHOOSEMENU_VBAR_XOFFSET (0*FILECHOOSEMENU_TEXT_WIDTH)
|
||||
#define FILECHOOSEMENU_VBAR_YOFFSET (FILECHOOSEMENU_FILE_YOFFSET)
|
||||
#define FILECHOOSEMENU_TEXT_HEIGHT (FILECHOOSEMENU_TEXT_SIZE * 8)
|
||||
#define FILECHOOSEMENU_TEXT_WIDTH (FILECHOOSEMENU_TEXT_SIZE * 6)
|
||||
#define FILECHOOSEMENU_MAX_FILENAME_SIZE 80
|
||||
#define FILECHOOSEMENU_MAX_LINELENGTH \
|
||||
(ARCADA_TFT_WIDTH / FILECHOOSEMENU_TEXT_WIDTH)
|
||||
#define FILECHOOSEMENU_MAX_LINES \
|
||||
((ARCADA_TFT_HEIGHT / FILECHOOSEMENU_TEXT_HEIGHT) - 2)
|
||||
#define FILECHOOSEMENU_FILE_XOFFSET (FILECHOOSEMENU_TEXT_WIDTH / 2)
|
||||
#define FILECHOOSEMENU_FILE_YOFFSET (2 * FILECHOOSEMENU_TEXT_HEIGHT)
|
||||
#define FILECHOOSEMENU_FILE_W ARCADA_TFT_WIDTH
|
||||
#define FILECHOOSEMENU_FILE_H \
|
||||
(FILECHOOSEMENU_MAX_LINES * FILECHOOSEMENU_TEXT_HEIGHT)
|
||||
#define FILECHOOSEMENU_FILE_BGCOLOR RGBVAL16(0x00, 0x00, 0x20)
|
||||
#define FILECHOOSEMENU_JOYS_YOFFSET (12 * FILECHOOSEMENU_TEXT_HEIGHT)
|
||||
#define FILECHOOSEMENU_VBAR_XOFFSET (0 * FILECHOOSEMENU_TEXT_WIDTH)
|
||||
#define FILECHOOSEMENU_VBAR_YOFFSET (FILECHOOSEMENU_FILE_YOFFSET)
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
#if defined(ADAFRUIT_HALLOWING)
|
||||
#include <Adafruit_ST7735.h>
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_FreeTouch.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI
|
||||
#define ARCADA_TFT_CS 39 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 38 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 37 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 7
|
||||
#define ARCADA_TFT_ROTATION 2
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 128
|
||||
#define ARCADA_TFT_HEIGHT 128
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 4
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A1
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_SPIFLASH_CS SS1
|
||||
#define ARCADA_SPIFLASH_SPI SPI1
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH accel = Adafruit_LIS3DH();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
_has_accel = true;
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
|
||||
if (!qt_1.begin() || !qt_2.begin() || !qt_3.begin() || !qt_4.begin()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7735 *tft = new Adafruit_ST7735(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->initR(INITR_144GREENTAB);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (qt_4.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
}
|
||||
if (qt_3.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
}
|
||||
if (qt_2.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
if (qt_1.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
Adafruit_FreeTouch qt_1 = Adafruit_FreeTouch(A2, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
Adafruit_FreeTouch qt_2 = Adafruit_FreeTouch(A3, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
Adafruit_FreeTouch qt_3 = Adafruit_FreeTouch(A4, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
Adafruit_FreeTouch qt_4 = Adafruit_FreeTouch(A5, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
#if defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
|
||||
#include <Adafruit_ST7789.h>
|
||||
#include <Adafruit_MSA301.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 0
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_TOUCHOUT_PIN 48
|
||||
#define ARCADA_SPEAKER_ENABLE 49
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 4
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_MSA301 accel = Adafruit_MSA301();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
_has_accel = true;
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
if (! accel.begin()) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel.setPowerMode(MSA301_NORMALMODE);
|
||||
accel.setDataRate(MSA301_DATARATE_1000_HZ);
|
||||
accel.setBandwidth(MSA301_BANDWIDTH_500_HZ);
|
||||
accel.setRange(MSA301_RANGE_4_G);
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
uint8_t rtna = 0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
tft->sendCommand(0xC6, &rtna, 1);
|
||||
tft->setSPISpeed(50000000); // yes fast
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A2) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
}
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A3) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
}
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A4) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A5) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t capRead(uint8_t outpin, uint8_t inpin, uint8_t num_readings=10) {
|
||||
pinMode(outpin, OUTPUT);
|
||||
pinMode(inpin, INPUT);
|
||||
|
||||
uint16_t counter = 0;
|
||||
for (int r=0; r<num_readings; r++) {
|
||||
digitalWrite(outpin, HIGH);
|
||||
while (!digitalRead(inpin)) {
|
||||
counter++;
|
||||
if (counter == 65535) { return 0; } // timed out
|
||||
}
|
||||
digitalWrite(outpin, LOW);
|
||||
delay(1);
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
#include "Adafruit_Arcada.h"
|
||||
|
||||
/*!
|
||||
@brief Loads BMP image file from QSPI or SD card directly to SPITFT screen.
|
||||
@brief Loads BMP image file from QSPI or SD card directly to SPITFT
|
||||
screen.
|
||||
@param filename
|
||||
Name of BMP image file to load.
|
||||
@param x
|
||||
|
|
@ -19,8 +20,10 @@
|
|||
@return One of the ImageReturnCode values (IMAGE_SUCCESS on successful
|
||||
completion, other values on failure).
|
||||
*/
|
||||
ImageReturnCode Adafruit_Arcada_SPITFT::drawBMP(char *filename, int16_t x, int16_t y, Adafruit_SPITFT *tft, boolean transact) {
|
||||
if (! tft) {
|
||||
ImageReturnCode Adafruit_Arcada_SPITFT::drawBMP(char *filename, int16_t x,
|
||||
int16_t y, Adafruit_SPITFT *tft,
|
||||
boolean transact) {
|
||||
if (!tft) {
|
||||
tft = display;
|
||||
}
|
||||
if (SD_imagereader) {
|
||||
|
|
@ -34,7 +37,7 @@ ImageReturnCode Adafruit_Arcada_SPITFT::drawBMP(char *filename, int16_t x, int16
|
|||
|
||||
/*!
|
||||
@brief Reques the ImageReader object used, either for SD or QSPI
|
||||
@return The activated ImageReader, or NULL if neither SD or QSPI
|
||||
@return The activated ImageReader, or NULL if neither SD or QSPI
|
||||
are available
|
||||
*/
|
||||
Adafruit_ImageReader *Adafruit_Arcada_SPITFT::getImageReader(void) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
// clang-format off
|
||||
|
||||
#if defined(__SAMD51__)
|
||||
|
||||
#if !defined(FLASH_PAGE_SIZE)
|
||||
#define FLASH_PAGE_SIZE (8 << NVMCTRL->PARAM.bit.PSZ)
|
||||
#define FLASH_PAGE_SIZE (8 << NVMCTRL->PARAM.bit.PSZ)
|
||||
#endif
|
||||
#define FLASH_NUM_PAGES NVMCTRL->PARAM.bit.NVMP
|
||||
#define FLASH_NUM_PAGES NVMCTRL->PARAM.bit.NVMP
|
||||
#if !defined(FLASH_SIZE)
|
||||
#define FLASH_SIZE (FLASH_PAGE_SIZE * FLASH_NUM_PAGES)
|
||||
#define FLASH_SIZE (FLASH_PAGE_SIZE * FLASH_NUM_PAGES)
|
||||
#endif
|
||||
#define FLASH_BLOCK_SIZE (FLASH_PAGE_SIZE * 16) // Datasheet 25.6.2
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ extern uint32_t __etext; // CODE END. Symbol exported from linker script
|
|||
static uint8_t *flashAddress = NULL; // Initted on first use below
|
||||
|
||||
// Skip writing blocks that are identical to the existing block.
|
||||
#define QUICK_FLASH 1 // only disable for debugging/timing!
|
||||
#define QUICK_FLASH 1 // only disable for debugging/timing!
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -27,22 +28,25 @@ static uint8_t *flashAddress = NULL; // Initted on first use below
|
|||
/**************************************************************************/
|
||||
uint32_t Adafruit_Arcada_SPITFT::availableFlash(void) {
|
||||
#if defined(__SAMD51__)
|
||||
if(flashAddress == NULL) {
|
||||
if (flashAddress == NULL) {
|
||||
// On first call, initialize flashAddress to first block boundary
|
||||
// following program storage. Code is uploaded page-at-a-time and
|
||||
// any trailing bytes in the last program block may be gibberish,
|
||||
// so we can't make use of that for ourselves.
|
||||
flashAddress = (uint8_t *)&__etext; // OK to overwrite the '0' there
|
||||
uint16_t partialBlock = (uint32_t)flashAddress % FLASH_BLOCK_SIZE;
|
||||
if(partialBlock) {
|
||||
if (partialBlock) {
|
||||
flashAddress += FLASH_BLOCK_SIZE - partialBlock;
|
||||
}
|
||||
// Move ahead one block. This shouldn't be necessary, but for
|
||||
// some reason certain programs are clobbering themselves.
|
||||
flashAddress += FLASH_BLOCK_SIZE;
|
||||
} else {
|
||||
// On subsequent calls, round up to next quadword (16 byte) boundary,
|
||||
// try packing some data into the trailing bytes of the last-used flash
|
||||
// block! Saves up to (8K-16) bytes flash per call.
|
||||
uint8_t partialQuadword = (uint32_t)flashAddress & 15;
|
||||
if(partialQuadword) {
|
||||
if (partialQuadword) {
|
||||
flashAddress += 16 - partialQuadword;
|
||||
}
|
||||
}
|
||||
|
|
@ -59,121 +63,135 @@ uint32_t Adafruit_Arcada_SPITFT::availableFlash(void) {
|
|||
*/
|
||||
/**************************************************************************/
|
||||
static inline void wait_ready(void) {
|
||||
while(!NVMCTRL->STATUS.bit.READY);
|
||||
do {
|
||||
yield();
|
||||
} while (!NVMCTRL->STATUS.bit.READY);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a block of data in RAM to the NEXT AVAILABLE position in flash memory (NOT a specific location).
|
||||
@brief Write a block of data in RAM to the NEXT AVAILABLE position in flash
|
||||
memory (NOT a specific location).
|
||||
@param ramAddress Pointer to source RAM data
|
||||
@param len Size in bytes of RAM data to store
|
||||
@return Pointer to stored data, NULL if insufficient space or an error.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t *Adafruit_Arcada_SPITFT::writeDataToFlash(uint8_t *ramAddress, uint32_t len) {
|
||||
uint8_t *Adafruit_Arcada_SPITFT::writeDataToFlash(uint8_t *ramAddress,
|
||||
uint32_t len) {
|
||||
#if defined(__SAMD51__)
|
||||
// availableFlash(), aside from reporting the amount of free flash memory,
|
||||
// also adjusts flashAddress to the first/next available usable boundary.
|
||||
// No need to do that manually here.
|
||||
if(len > availableFlash()) {
|
||||
if (len > availableFlash()) {
|
||||
Serial.println("Too large!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t saveCache = NVMCTRL->CTRLA.reg; // Cache in Rev a silicon
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS0 = true; // isn't reliable when
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS1 = true; // writing to NVM.
|
||||
// Check if data's already there...if so, most of the work can be skipped.
|
||||
if (memcmp(ramAddress, flashAddress, len)) {
|
||||
|
||||
// Set manual write mode - only needed once, not in loop
|
||||
NVMCTRL->CTRLA.bit.WMODE = NVMCTRL_CTRLA_WMODE_MAN;
|
||||
// Not there, must be stored...
|
||||
uint16_t saveNVMconfig = NVMCTRL->CTRLA.reg; // Save NVM config
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS0 = 1; // Disable AHB caches,
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS1 = 1; // unreliable in Rev A silicon
|
||||
NVMCTRL->CTRLA.bit.WMODE = NVMCTRL_CTRLA_WMODE_MAN; // Manual write mode
|
||||
|
||||
// Clear page buffer, only needed once, quadword write also clears it
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_PBC;
|
||||
// Clear page buffer, only needed once, quadword write also clears it
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_PBC;
|
||||
|
||||
for(uint8_t tries = 0;;) { // Repeat write sequence until success or limit
|
||||
for (uint8_t tries = 0;;) { // Repeat write until success or limit reached
|
||||
|
||||
uint8_t *src = (uint8_t *)ramAddress; // Maintain passed-in pointers,
|
||||
uint32_t *dst = (uint32_t *)flashAddress; // modify these instead.
|
||||
int32_t bytesThisPass, bytesToGo = len;
|
||||
uint8_t *src = (uint8_t *)ramAddress; // Maintain passed-in pointers,
|
||||
uint32_t *dst = (uint32_t *)flashAddress; // modify these instead.
|
||||
int32_t bytesThisPass, bytesToGo = len;
|
||||
|
||||
Serial.print("Storing");
|
||||
wait_ready(); // Wait for any NVM write op in progress
|
||||
Serial.print("Storing..");
|
||||
wait_ready(); // Wait for any NVM write op in progress
|
||||
|
||||
while(bytesToGo > 0) {
|
||||
yield();
|
||||
// Because dst (via flashAddress) is always quadword-aligned at this
|
||||
// point, and flash blocks are known to be a quadword-multiple size,
|
||||
// this comparison is reasonable for checking for start of block...
|
||||
if(!((uint32_t)dst % FLASH_BLOCK_SIZE)) { // At block boundary
|
||||
// If ANY changed data within the entire block, it must be erased
|
||||
bytesThisPass = min(FLASH_BLOCK_SIZE, bytesToGo);
|
||||
if(memcmp(src, dst, bytesThisPass)) { // >0 if different
|
||||
Serial.write('-'); // minus = erasing
|
||||
wait_ready();
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst; // Destination address in flash
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_EB;
|
||||
} else { // Skip entire block
|
||||
Serial.print(">>"); // >> = skipping, already stored
|
||||
bytesToGo -= bytesThisPass;
|
||||
src += FLASH_BLOCK_SIZE; // Advance to next block
|
||||
dst += FLASH_BLOCK_SIZE / 4;
|
||||
continue;
|
||||
while (bytesToGo > 0) {
|
||||
yield();
|
||||
// Because dst (via flashAddress) is always quadword-aligned at this
|
||||
// point, and flash blocks are known to be a quadword-multiple size,
|
||||
// this comparison is reasonable for checking for start of block...
|
||||
if (!((uint32_t)dst % FLASH_BLOCK_SIZE)) { // At block boundary
|
||||
// If ANY changed data within the entire block, it must be erased
|
||||
bytesThisPass = min(FLASH_BLOCK_SIZE, bytesToGo);
|
||||
if (memcmp(src, dst, bytesThisPass)) { // >0 if different
|
||||
Serial.write('-'); // minus = erasing
|
||||
wait_ready();
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst; // Destination address in flash
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_EB;
|
||||
} else { // Block hasn't changed, skip it (keep old data)
|
||||
Serial.print(">"); // >> = skipping, already stored
|
||||
bytesToGo -= bytesThisPass;
|
||||
src += FLASH_BLOCK_SIZE; // Advance to next block
|
||||
dst += FLASH_BLOCK_SIZE / 4;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Examine next quadword, write only if needed (reduce flash wear)
|
||||
bytesThisPass = min(16, bytesToGo);
|
||||
if(memcmp(src, dst, bytesThisPass)) { // >0 if different
|
||||
if(!((uint32_t)dst & 2047)) Serial.write('.'); // One . per 2KB
|
||||
// Write next quadword (16 bytes) to flash
|
||||
bytesThisPass = min(16, bytesToGo);
|
||||
if (!((uint32_t)dst & 2047))
|
||||
Serial.write('.'); // One . per 2KB
|
||||
// src might not be 32-bit aligned and must be read byte-at-a-time.
|
||||
// dst write ops MUST be 32-bit! Won't work with memcpy().
|
||||
dst[0] = src[ 0] | (src[ 1]<<8) | (src[ 2]<<16) | (src[ 3]<<24);
|
||||
dst[1] = src[ 4] | (src[ 5]<<8) | (src[ 6]<<16) | (src[ 7]<<24);
|
||||
dst[2] = src[ 8] | (src[ 9]<<8) | (src[10]<<16) | (src[11]<<24);
|
||||
dst[3] = src[12] | (src[13]<<8) | (src[14]<<16) | (src[15]<<24);
|
||||
dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
|
||||
dst[1] = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
|
||||
dst[2] = src[8] | (src[9] << 8) | (src[10] << 16) | (src[11] << 24);
|
||||
dst[3] = src[12] | (src[13] << 8) | (src[14] << 16) | (src[15] << 24);
|
||||
// Trigger the quadword write
|
||||
wait_ready();
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst;
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst;
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_WQW;
|
||||
}
|
||||
bytesToGo -= bytesThisPass;
|
||||
src += 16; // Advance to next quadword
|
||||
dst += 4;
|
||||
}
|
||||
|
||||
wait_ready(); // Wait for last write to finish
|
||||
bytesToGo -= bytesThisPass;
|
||||
src += 16; // Advance to next quadword
|
||||
dst += 4;
|
||||
} // end bytesToGo write loop
|
||||
|
||||
Serial.print("verify..."); Serial.flush();
|
||||
if(memcmp(ramAddress, flashAddress, len)) { // nonzero if mismatch
|
||||
if(++tries >= 4) {
|
||||
Serial.println("...proceeding anyway");
|
||||
break; // Give up, run with the data we have
|
||||
}
|
||||
// If we didn't start at a block boundary...
|
||||
if(uint32_t q = (uint32_t)flashAddress % FLASH_BLOCK_SIZE) {
|
||||
// Get index of first changed byte
|
||||
uint32_t n;
|
||||
for(n=0; (ramAddress[n] == flashAddress[n]) &&
|
||||
(n <= FLASH_BLOCK_SIZE); n++);
|
||||
// ...and if first mismatched byte is within the region before
|
||||
// the first block boundary...
|
||||
q = FLASH_BLOCK_SIZE - q; // Bytes in partial 1st block
|
||||
if(n < q) {
|
||||
// ...then flashAddress MUST be advanced to the next block
|
||||
// boundary before we retry, reason being that we CAN'T erase
|
||||
// the initial partial block (it may be preceded by other data).
|
||||
flashAddress = &flashAddress[q];
|
||||
wait_ready(); // Wait for last write to finish
|
||||
|
||||
Serial.print("verify...");
|
||||
|
||||
if (memcmp(ramAddress, flashAddress, len)) { // If mismatch...
|
||||
if (++tries >= 4) {
|
||||
Serial.println("proceeding anyway");
|
||||
break; // Give up, run with the data we have
|
||||
}
|
||||
// If the write didn't start at a block boundary...
|
||||
if (uint32_t q = (uint32_t)flashAddress % FLASH_BLOCK_SIZE) {
|
||||
q = FLASH_BLOCK_SIZE - q; // Remaining bytes within first block
|
||||
// Does the mismatch start within the first partial block?
|
||||
if (memcmp(ramAddress, flashAddress, min(len, q))) {
|
||||
// ...then flashAddress MUST be advanced to the next block start
|
||||
// before retrying, reason being that we CAN'T erase the initial
|
||||
// partial block (it may be preceded by other data).
|
||||
Serial.print("next block...");
|
||||
flashAddress = &flashAddress[q];
|
||||
// And if flashAddress changes (could be 1 byte to 8K), that means
|
||||
// we need to re-test whether the data to write will fit in the
|
||||
// remaining space, else code might get clobbered (whether at end
|
||||
// or if it wraps around).
|
||||
if (len > availableFlash()) {
|
||||
Serial.println("won't fit.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Serial.println("retrying...");
|
||||
} else {
|
||||
Serial.println("OK");
|
||||
break;
|
||||
}
|
||||
Serial.println("...retrying..."); Serial.flush();
|
||||
} else {
|
||||
Serial.println("OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NVMCTRL->CTRLA.reg = saveCache; // Restore NVM cache settings
|
||||
NVMCTRL->CTRLA.reg = saveNVMconfig; // Restore NVM cache settings
|
||||
} else {
|
||||
Serial.println("Already in flash");
|
||||
}
|
||||
|
||||
// Return value will be start of newly-written data in flash
|
||||
uint8_t *returnVal = flashAddress;
|
||||
|
|
@ -188,14 +206,17 @@ uint8_t *Adafruit_Arcada_SPITFT::writeDataToFlash(uint8_t *ramAddress, uint32_t
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Opens a file and writes the data contents to the internal chip flash memory. NOT the QSPI flash but the actual chip memory!
|
||||
@param filename A string with the filename path, can be relative or absolute.
|
||||
@brief Opens a file and writes the data contents to the internal chip flash
|
||||
memory. NOT the QSPI flash but the actual chip memory!
|
||||
@param filename A string with the filename path, can be relative or
|
||||
absolute.
|
||||
@return A pointer to the flash memory address, or NULL on failure.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t * Adafruit_Arcada_SPITFT::writeFileToFlash(const char *filename) {
|
||||
uint8_t *Adafruit_Arcada_SPITFT::writeFileToFlash(const char *filename) {
|
||||
File f = open(filename);
|
||||
if (!f) return NULL;
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
uint32_t filesize = f.fileSize();
|
||||
Serial.printf("Filesize : %d bytes\n", filesize);
|
||||
|
|
@ -210,55 +231,54 @@ uint8_t * Adafruit_Arcada_SPITFT::writeFileToFlash(const char *filename) {
|
|||
|
||||
uint8_t blockBuf[FLASH_BLOCK_SIZE];
|
||||
|
||||
uint16_t saveCache = NVMCTRL->CTRLA.reg; // Cache in Rev a silicon
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS0 = true; // isn't reliable when
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS1 = true; // writing to NVM.
|
||||
|
||||
// Set manual write mode - only needed once, not in loop
|
||||
NVMCTRL->CTRLA.bit.WMODE = NVMCTRL_CTRLA_WMODE_MAN;
|
||||
uint16_t saveNVMconfig = NVMCTRL->CTRLA.reg; // Save NVM config
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS0 = 1; // Disable AHB caches,
|
||||
NVMCTRL->CTRLA.bit.CACHEDIS1 = 1; // unreliable in Rev A silicon
|
||||
NVMCTRL->CTRLA.bit.WMODE = NVMCTRL_CTRLA_WMODE_MAN; // Manual write mode
|
||||
|
||||
// Clear page buffer, only needed once, quadword write also clears it
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_PBC;
|
||||
|
||||
uint8_t *src = (uint8_t *)blockBuf;
|
||||
uint8_t *src = (uint8_t *)blockBuf;
|
||||
uint32_t *dst = (uint32_t *)flashAddress;
|
||||
int32_t bytesThisPass, bytesToGo = filesize;
|
||||
int32_t bytesThisPass, bytesToGo = filesize;
|
||||
|
||||
Serial.print("Storing");
|
||||
wait_ready(); // Wait for any NVM write op in progress
|
||||
|
||||
while(bytesToGo > 0) {
|
||||
while (bytesToGo > 0) {
|
||||
yield();
|
||||
|
||||
// Because sequential calls aim to 'pack' data within blocks,
|
||||
// the first write isn't necessarily FLASH_BLOCK_SIZE bytes,
|
||||
// it may be less depending on prior data in the current block.
|
||||
bytesThisPass = FLASH_BLOCK_SIZE - ((uint32_t)dst % FLASH_BLOCK_SIZE);
|
||||
if(bytesThisPass > bytesToGo) bytesThisPass = bytesToGo;
|
||||
if (bytesThisPass > bytesToGo)
|
||||
bytesThisPass = bytesToGo;
|
||||
|
||||
memset(blockBuf, 0xFF, sizeof blockBuf);
|
||||
if(f.read(blockBuf, bytesThisPass) != bytesThisPass) {
|
||||
if (f.read(blockBuf, bytesThisPass) != bytesThisPass) {
|
||||
Serial.printf("File read %d bytes failed!", bytesThisPass);
|
||||
return NULL;
|
||||
}
|
||||
//Serial.printf("bytesToGo: %d\n", bytesToGo);
|
||||
//Serial.printf("bytesThisPass: %d\n", bytesThisPass);
|
||||
//Serial.printf("dst: %d\n", (uint32_t)dst);
|
||||
// Serial.printf("bytesToGo: %d\n", bytesToGo);
|
||||
// Serial.printf("bytesThisPass: %d\n", bytesThisPass);
|
||||
// Serial.printf("dst: %d\n", (uint32_t)dst);
|
||||
|
||||
// Because dst (via flashAddress) is always quadword-aligned at this
|
||||
// point, and flash blocks are known to be a quadword-multiple size,
|
||||
// this comparison is reasonable for checking for start of block...
|
||||
if(!((uint32_t)dst % FLASH_BLOCK_SIZE)) { // At block boundary
|
||||
if (!((uint32_t)dst % FLASH_BLOCK_SIZE)) { // At block boundary
|
||||
// If ANY changed data within the entire block, it must be erased
|
||||
if(memcmp(src, dst, bytesThisPass)) { // >0 if different
|
||||
Serial.write('-'); // minus = erasing
|
||||
if (memcmp(src, dst, bytesThisPass)) { // >0 if different
|
||||
Serial.write('-'); // minus = erasing
|
||||
wait_ready();
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst; // Destination address in flash
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst; // Destination address in flash
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_EB;
|
||||
} else { // Skip entire block
|
||||
Serial.print(">>"); // >> = skipping, already stored
|
||||
} else { // Skip entire block
|
||||
Serial.print(">>"); // >> = skipping, already stored
|
||||
bytesToGo -= bytesThisPass;
|
||||
dst += FLASH_BLOCK_SIZE / 4; // Advance to next block
|
||||
dst += FLASH_BLOCK_SIZE / 4; // Advance to next block
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -270,26 +290,27 @@ uint8_t * Adafruit_Arcada_SPITFT::writeFileToFlash(const char *filename) {
|
|||
// Write bytesThisPass from blockBuf to flash, using quadwords
|
||||
int quadwordBytes;
|
||||
int countdown = bytesThisPass;
|
||||
while(countdown > 0) {
|
||||
while (countdown > 0) {
|
||||
// Examine next quadword, write only if needed (reduce flash wear)
|
||||
quadwordBytes = min(16, bytesToGo);
|
||||
// if(memcmp(src, dst, quadwordBytes)) { // >0 if different
|
||||
if(1) {
|
||||
if(!((uint32_t)dst & 2047)) Serial.write('.'); // One . per 2KB
|
||||
// if(memcmp(src, dst, quadwordBytes)) { // >0 if different
|
||||
if (1) {
|
||||
if (!((uint32_t)dst & 2047))
|
||||
Serial.write('.'); // One . per 2KB
|
||||
// src might not be 32-bit aligned and must be read byte-at-a-time.
|
||||
// dst write ops MUST be 32-bit! Won't work with memcpy().
|
||||
dst[0] = src[ 0] | (src[ 1]<<8) | (src[ 2]<<16) | (src[ 3]<<24);
|
||||
dst[1] = src[ 4] | (src[ 5]<<8) | (src[ 6]<<16) | (src[ 7]<<24);
|
||||
dst[2] = src[ 8] | (src[ 9]<<8) | (src[10]<<16) | (src[11]<<24);
|
||||
dst[3] = src[12] | (src[13]<<8) | (src[14]<<16) | (src[15]<<24);
|
||||
dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
|
||||
dst[1] = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
|
||||
dst[2] = src[8] | (src[9] << 8) | (src[10] << 16) | (src[11] << 24);
|
||||
dst[3] = src[12] | (src[13] << 8) | (src[14] << 16) | (src[15] << 24);
|
||||
// Trigger the quadword write
|
||||
wait_ready();
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst;
|
||||
NVMCTRL->ADDR.reg = (uint32_t)dst;
|
||||
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_WQW;
|
||||
}
|
||||
countdown -= quadwordBytes;
|
||||
src += 16; // Advance to next quadword
|
||||
dst += 4;
|
||||
src += 16; // Advance to next quadword
|
||||
dst += 4;
|
||||
}
|
||||
bytesToGo -= bytesThisPass;
|
||||
} // end of file
|
||||
|
|
@ -300,39 +321,39 @@ uint8_t * Adafruit_Arcada_SPITFT::writeFileToFlash(const char *filename) {
|
|||
Serial.println("Verifying!");
|
||||
f.rewind();
|
||||
bytesToGo = filesize;
|
||||
while(bytesToGo > 0) {
|
||||
while (bytesToGo > 0) {
|
||||
yield();
|
||||
memset(blockBuf, 0xFF, sizeof blockBuf);
|
||||
bytesThisPass = min((uint32_t)bytesToGo, sizeof blockBuf);
|
||||
if(f.read(blockBuf, bytesThisPass) != bytesThisPass) {
|
||||
if (f.read(blockBuf, bytesThisPass) != bytesThisPass) {
|
||||
Serial.printf("File read %d bytes failed!", bytesThisPass);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(memcmp(src, dst, bytesThisPass)) {
|
||||
if (memcmp(src, dst, bytesThisPass)) {
|
||||
Serial.printf("Failed at address %d\n", (uint32_t)dst);
|
||||
/* Verification dump:
|
||||
uint8_t *foo = (uint8_t *)blockBuf, *bar = (uint8_t *)dst;
|
||||
Serial.print("Expected: ");
|
||||
for(int i=0; i<bytesThisPass; i++) {
|
||||
Serial.printf("%02x ", foo[i]);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print("Got: ");
|
||||
for(int i=0; i<bytesThisPass; i++) {
|
||||
Serial.printf("%02x ", bar[i]);
|
||||
}
|
||||
Serial.println();
|
||||
*/
|
||||
/* Verification dump:
|
||||
uint8_t *foo = (uint8_t *)blockBuf, *bar = (uint8_t *)dst;
|
||||
Serial.print("Expected: ");
|
||||
for(int i=0; i<bytesThisPass; i++) {
|
||||
Serial.printf("%02x ", foo[i]);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print("Got: ");
|
||||
for(int i=0; i<bytesThisPass; i++) {
|
||||
Serial.printf("%02x ", bar[i]);
|
||||
}
|
||||
Serial.println();
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
bytesToGo -= bytesThisPass;
|
||||
dst += bytesThisPass / 4;
|
||||
dst += bytesThisPass / 4;
|
||||
}
|
||||
|
||||
NVMCTRL->CTRLA.reg = saveCache; // Restore NVM cache settings
|
||||
NVMCTRL->CTRLA.reg = saveNVMconfig; // Restore NVM cache settings
|
||||
|
||||
// Return value will be start of newly-written data in flash
|
||||
uint8_t *returnVal = flashAddress;
|
||||
|
|
@ -344,4 +365,4 @@ Serial.println();
|
|||
return 0; // unsupported chip
|
||||
#endif
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
#include <Adafruit_ST7789.h>
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI
|
||||
#define ARCADA_TFT_CS 5 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 6 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 4 // Display reset Arduino pin number
|
||||
#define ARCADA_LEFTTFT_SPI SPI1
|
||||
#define ARCADA_LEFTTFT_CS 9 // Display CS Arduino pin number
|
||||
#define ARCADA_LEFTTFT_DC 10 // Display D/C Arduino pin number
|
||||
#define ARCADA_LEFTTFT_RST -1 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 21
|
||||
#define ARCADA_TFT_ROTATION 0
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 20
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define SS_LIGHTSENSOR_PIN 2
|
||||
#define SS_VCCSENSOR_PIN 3
|
||||
#define SS_BACKLIGHT_PIN 5
|
||||
#define SS_TFTRESET_PIN 8
|
||||
#define SS_SWITCH1_PIN 9
|
||||
#define SS_SWITCH2_PIN 10
|
||||
#define SS_SWITCH3_PIN 11
|
||||
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 3
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC3_Handler
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH accel = Adafruit_LIS3DH();
|
||||
Adafruit_seesaw ss;
|
||||
Adafruit_ST7789 *display2, *_display; // we need to keep a 'copy' of the ST7789 version of both displays
|
||||
|
||||
Adafruit_Arcada() {
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
if(!ss.begin(0x49, -1, false)) {
|
||||
return false;
|
||||
}
|
||||
ss.pinMode(SS_SWITCH1_PIN, INPUT_PULLUP);
|
||||
ss.pinMode(SS_SWITCH2_PIN, INPUT_PULLUP);
|
||||
ss.pinMode(SS_SWITCH3_PIN, INPUT_PULLUP);
|
||||
// reset TFT
|
||||
ss.pinMode(SS_TFTRESET_PIN, OUTPUT);
|
||||
ss.digitalWrite(SS_TFTRESET_PIN, LOW);
|
||||
delay(10);
|
||||
ss.digitalWrite(SS_TFTRESET_PIN, HIGH);
|
||||
delay(10);
|
||||
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
_has_accel = false; // couldn't find accelerometer, could be a pybadge LC
|
||||
} else {
|
||||
_has_accel = true;
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void begin(uint32_t freq) {
|
||||
_display->init(240, 240);
|
||||
display2->init(240, 240);
|
||||
}
|
||||
|
||||
void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
display->setAddrWindow(x, y, w, h);
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
_display = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
display2 = new Adafruit_ST7789(&ARCADA_LEFTTFT_SPI, ARCADA_LEFTTFT_CS, ARCADA_LEFTTFT_DC, ARCADA_LEFTTFT_RST);
|
||||
_display->init(240, 240);
|
||||
display2->init(240, 240);
|
||||
|
||||
uint8_t rtna = 0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
_display->sendCommand(0xC6, &rtna, 1);
|
||||
display2->sendCommand(0xC6, &rtna, 1);
|
||||
|
||||
_display->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display2->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
_display->setRotation(ARCADA_TFT_ROTATION);
|
||||
display2->setRotation(ARCADA_TFT_ROTATION);
|
||||
_display->setSPISpeed(50000000); // yes fast
|
||||
display2->setSPISpeed(50000000); // 50 MHz!
|
||||
display = _display; // grab the SPITFT pointer for arcada parent
|
||||
}
|
||||
|
||||
uint16_t readLightSensor(void) {
|
||||
return ss.analogRead(SS_LIGHTSENSOR_PIN);
|
||||
}
|
||||
|
||||
float readBatterySensor(void) {
|
||||
return ss.analogRead(SS_VCCSENSOR_PIN)*2*3.3/1024;
|
||||
}
|
||||
|
||||
bool setBacklight(uint8_t brightness, bool saveToDisk=false) {
|
||||
// for left tft
|
||||
ss.analogWrite(SS_BACKLIGHT_PIN, brightness);
|
||||
// handle parentally
|
||||
return Adafruit_Arcada_SPITFT::setBacklight(brightness, saveToDisk);
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (! ss.digitalRead(SS_SWITCH1_PIN))
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
if (! ss.digitalRead(SS_SWITCH2_PIN))
|
||||
buttons |= ARCADA_BUTTONMASK_A;
|
||||
if (! ss.digitalRead(SS_SWITCH3_PIN))
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#ifndef __ARCADA_PYBADGE_M4__
|
||||
#define __ARCADA_PYBADGE_M4__
|
||||
#if defined(ADAFRUIT_PYBADGE_M4_EXPRESS)
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7735.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 1
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x7BEF
|
||||
#define ARCADA_TFT_WIDTH 160
|
||||
#define ARCADA_TFT_HEIGHT 128
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 51
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 5
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_BUTTON_CLOCK 48
|
||||
#define ARCADA_BUTTON_DATA 49
|
||||
#define ARCADA_BUTTON_LATCH 50
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0x80
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0x40
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0x20
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0x10
|
||||
#define ARCADA_BUTTON_SHIFTMASK_LEFT 0x01
|
||||
#define ARCADA_BUTTON_SHIFTMASK_UP 0x02
|
||||
#define ARCADA_BUTTON_SHIFTMASK_DOWN 0x04
|
||||
#define ARCADA_BUTTON_SHIFTMASK_RIGHT 0x08
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
#include "arcadatype.h"
|
||||
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH accel = Adafruit_LIS3DH();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
_has_accel = false; // couldn't find accelerometer, could be a pybadge LC
|
||||
} else {
|
||||
_has_accel = true;
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7735 *tft = new Adafruit_ST7735(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->initR(INITR_BLACKTAB);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#if defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
|
||||
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7735.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 1
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_WIDTH 160
|
||||
#define ARCADA_TFT_HEIGHT 128
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 51
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 5
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_BUTTON_CLOCK 48
|
||||
#define ARCADA_BUTTON_DATA 49
|
||||
#define ARCADA_BUTTON_LATCH 50
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0x80
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0x40
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0x20
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0x10
|
||||
|
||||
#define ARCADA_JOYSTICK_X A11
|
||||
#define ARCADA_JOYSTICK_Y A10
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_SD_CS 4
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH accel = Adafruit_LIS3DH();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
_has_accel = true;
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7735 *tft = new Adafruit_ST7735(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->initR(INITR_BLACKTAB);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
#if defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)
|
||||
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 3
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_WIDTH 320
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 51
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 5
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_BUTTON_CLOCK 48
|
||||
#define ARCADA_BUTTON_DATA 49
|
||||
#define ARCADA_BUTTON_LATCH 50
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0x80
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0x40
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0x20
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0x10
|
||||
|
||||
#define ARCADA_JOYSTICK_X A11
|
||||
#define ARCADA_JOYSTICK_Y A10
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_SD_CS 4
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH accel = Adafruit_LIS3DH();
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
_has_accel = true;
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
if (! accel.begin(0x18) && ! accel.begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 320);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#if defined(ADAFRUIT_PYPORTAL)
|
||||
#include <WiFiNINA.h>
|
||||
#include <Adafruit_ILI9341.h>
|
||||
|
||||
// 8 bit 320x240 TFT
|
||||
#define ARCADA_TFT_D0 34 // Data bit 0 pin (MUST be on PORT byte boundary)
|
||||
#define ARCADA_TFT_WR 26 // Write-strobe pin (CCL-inverted timer output)
|
||||
#define ARCADA_TFT_DC 10 // Data/command pin
|
||||
#define ARCADA_TFT_CS 11 // Chip-select pin
|
||||
#define ARCADA_TFT_RST 24 // Reset pin
|
||||
#define ARCADA_TFT_RD 9 // Read-strobe pin
|
||||
#define ARCADA_TFT_LITE 25
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_ROTATION 3
|
||||
#define ARCADA_TFT_WIDTH 320
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 50
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 2
|
||||
#define ARCADA_NEOPIXEL_NUM 1
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A2
|
||||
|
||||
#define ARCADA_SD_CS 32
|
||||
|
||||
#define ARCADA_TOUCHSCREEN_YM A6
|
||||
#define ARCADA_TOUCHSCREEN_XP A5
|
||||
#define ARCADA_TOUCHSCREEN_YP A4
|
||||
#define ARCADA_TOUCHSCREEN_XM A7
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MIN 325
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MAX 750
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MIN 840
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MAX 240
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
|
||||
Adafruit_Arcada(void) {
|
||||
};
|
||||
|
||||
bool variantBegin(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ILI9341 *tft = new Adafruit_ILI9341(tft8bitbus, ARCADA_TFT_D0, ARCADA_TFT_WR, ARCADA_TFT_DC, ARCADA_TFT_CS, ARCADA_TFT_RST, ARCADA_TFT_RD);
|
||||
tft->begin();
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
|
||||
//#define ARCADA_MSD_DEBUG
|
||||
// #define ARCADA_MSD_DEBUG
|
||||
|
||||
static uint32_t last_access_ms;
|
||||
|
||||
|
|
@ -11,9 +11,9 @@ static Adafruit_USBD_MSC usb_msc;
|
|||
extern FatFileSystem Arcada_QSPI_FileSys;
|
||||
extern Adafruit_SPIFlash Arcada_QSPI_Flash;
|
||||
|
||||
int32_t qspi_msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize);
|
||||
int32_t qspi_msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize);
|
||||
void qspi_msc_flush_cb (void);
|
||||
int32_t qspi_msc_write_cb(uint32_t lba, uint8_t *buffer, uint32_t bufsize);
|
||||
int32_t qspi_msc_read_cb(uint32_t lba, void *buffer, uint32_t bufsize);
|
||||
void qspi_msc_flush_cb(void);
|
||||
|
||||
#if defined(ENABLE_EXTENDED_TRANSFER_CLASS)
|
||||
extern SdFatEX Arcada_SD_FileSys;
|
||||
|
|
@ -21,67 +21,96 @@ extern SdFatEX Arcada_SD_FileSys;
|
|||
extern SdFat Arcada_SD_FileSys;
|
||||
#endif
|
||||
|
||||
int32_t sd_msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize);
|
||||
int32_t sd_msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize);
|
||||
void sd_msc_flush_cb (void);
|
||||
|
||||
int32_t sd_msc_write_cb(uint32_t lba, uint8_t *buffer, uint32_t bufsize);
|
||||
int32_t sd_msc_read_cb(uint32_t lba, void *buffer, uint32_t bufsize);
|
||||
void sd_msc_flush_cb(void);
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Make the raw filesystem of the Arcada board available over USB
|
||||
@param desiredFilesys The filesystem we'd prefer to use, can be ARCADA_FILESYS_SD, ARCADA_FILESYS_QSPI, or ARCADA_FILESYS_SD_AND_QSPI
|
||||
@param desiredFilesys The filesystem we'd prefer to use, can be
|
||||
ARCADA_FILESYS_SD, ARCADA_FILESYS_QSPI, or ARCADA_FILESYS_SD_AND_QSPI
|
||||
@return True on success, false on failure
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::filesysBeginMSD(Arcada_FilesystemType desiredFilesys) {
|
||||
bool Adafruit_Arcada_SPITFT::filesysBeginMSD(
|
||||
Arcada_FilesystemType desiredFilesys) {
|
||||
(void)desiredFilesys;
|
||||
|
||||
#if defined(USE_TINYUSB)
|
||||
Arcada_FilesystemType found = filesysBegin(desiredFilesys);
|
||||
|
||||
if (found == ARCADA_FILESYS_NONE) { return false; }
|
||||
if (found == ARCADA_FILESYS_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (found == ARCADA_FILESYS_SD || found == ARCADA_FILESYS_SD_AND_QSPI) { // SD first
|
||||
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively
|
||||
// arcadaBegin() could take long time to complete
|
||||
// By the time this function is called, usb enumeration is probably completed
|
||||
// as CDC only device Therefore we have to
|
||||
// - Physically detach the device by disable pull-up resistor
|
||||
// - Configure the Mass Stroage interface
|
||||
// - Re-attach by enable pull-up resistor
|
||||
USBDevice.detach();
|
||||
delay(50); // a bit of delay for device to disconnect
|
||||
|
||||
if (found == ARCADA_FILESYS_SD ||
|
||||
found == ARCADA_FILESYS_SD_AND_QSPI) { // SD first
|
||||
// Set disk vendor id, product id and revision with string up to 8, 16, 4
|
||||
// characters respectively
|
||||
usb_msc.setID("Adafruit", "SD Card", "1.0");
|
||||
|
||||
|
||||
// Set callback
|
||||
usb_msc.setReadWriteCallback(sd_msc_read_cb, sd_msc_write_cb, sd_msc_flush_cb);
|
||||
usb_msc.setReadWriteCallback(sd_msc_read_cb, sd_msc_write_cb,
|
||||
sd_msc_flush_cb);
|
||||
usb_msc.setUnitReady(false);
|
||||
usb_msc.begin();
|
||||
|
||||
uint32_t block_count = Arcada_SD_FileSys.card()->cardSize();
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
|
||||
uint32_t block_count = Arcada_SD_FileSys.card()->sectorCount();
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.print("MSD for SD Card - Volume size (MB): ");
|
||||
Serial.println((block_count/2) / 1024);
|
||||
#endif
|
||||
Serial.println((block_count / 2) / 1024);
|
||||
#endif
|
||||
// Set disk size, SD block size is always 512
|
||||
usb_msc.setCapacity(block_count, 512);
|
||||
|
||||
|
||||
// MSC is ready for read/write
|
||||
usb_msc.setUnitReady(true);
|
||||
usb_msc.setUnitReady(true);
|
||||
|
||||
// re-attach to usb bus
|
||||
USBDevice.attach();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (found == ARCADA_FILESYS_QSPI ||
|
||||
if (found == ARCADA_FILESYS_QSPI ||
|
||||
found == ARCADA_FILESYS_SD_AND_QSPI) { // QSPI if not SD
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.println("Found QSPI for MSD");
|
||||
Serial.print("JEDEC ID: "); Serial.println(Arcada_QSPI_Flash.getJEDECID(), HEX);
|
||||
Serial.print("Flash size: "); Serial.println(Arcada_QSPI_Flash.size());
|
||||
#endif
|
||||
Serial.print("JEDEC ID: ");
|
||||
Serial.println(Arcada_QSPI_Flash.getJEDECID(), HEX);
|
||||
Serial.print("Flash size: ");
|
||||
Serial.println(Arcada_QSPI_Flash.size());
|
||||
#endif
|
||||
|
||||
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively
|
||||
// Set disk vendor id, product id and revision with string up to 8, 16, 4
|
||||
// characters respectively
|
||||
usb_msc.setID("Adafruit", "SPI Flash", "1.0");
|
||||
|
||||
|
||||
// Set callback
|
||||
usb_msc.setReadWriteCallback(qspi_msc_read_cb, qspi_msc_write_cb, qspi_msc_flush_cb);
|
||||
usb_msc.setReadWriteCallback(qspi_msc_read_cb, qspi_msc_write_cb,
|
||||
qspi_msc_flush_cb);
|
||||
|
||||
// Set disk size, block size should be 512 regardless of spi flash page size
|
||||
usb_msc.setCapacity(Arcada_QSPI_Flash.pageSize()*Arcada_QSPI_Flash.numPages()/512, 512);
|
||||
usb_msc.setCapacity(
|
||||
Arcada_QSPI_Flash.pageSize() * Arcada_QSPI_Flash.numPages() / 512, 512);
|
||||
|
||||
// MSC is ready for read/write
|
||||
usb_msc.setUnitReady(true);
|
||||
usb_msc.setUnitReady(true);
|
||||
usb_msc.begin();
|
||||
|
||||
// re-attach to usb bus
|
||||
USBDevice.attach();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -97,49 +126,52 @@ bool Adafruit_Arcada_SPITFT::filesysBeginMSD(Arcada_FilesystemType desiredFilesy
|
|||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::recentUSB(uint32_t timeout) {
|
||||
(void)timeout;
|
||||
|
||||
#if defined(USE_TINYUSB)
|
||||
uint32_t curr_time = millis();
|
||||
if (last_access_ms > curr_time) { // oi, rollover
|
||||
if (last_access_ms > curr_time) { // oi, rollover
|
||||
return false;
|
||||
}
|
||||
if ((last_access_ms + timeout) >= curr_time) {
|
||||
return true; // indeed!
|
||||
return true; // indeed!
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// Callback invoked when received READ10 command.
|
||||
// Copy disk's data to buffer (up to bufsize) and
|
||||
// return number of copied bytes (must be multiple of block size)
|
||||
int32_t qspi_msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
// Copy disk's data to buffer (up to bufsize) and
|
||||
// return number of copied bytes (must be multiple of block size)
|
||||
int32_t qspi_msc_read_cb(uint32_t lba, void *buffer, uint32_t bufsize) {
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.printf("QSPI Read block %08x\n", lba);
|
||||
#endif
|
||||
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
|
||||
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
|
||||
return Arcada_QSPI_Flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512) ? bufsize : -1;
|
||||
// already include 4K sector caching internally. We don't need to cache it,
|
||||
// yahhhh!!
|
||||
return Arcada_QSPI_Flash.readBlocks(lba, (uint8_t *)buffer, bufsize / 512)
|
||||
? bufsize
|
||||
: -1;
|
||||
}
|
||||
|
||||
// Callback invoked when received WRITE10 command.
|
||||
// Process data in buffer to disk's storage and
|
||||
// Process data in buffer to disk's storage and
|
||||
// return number of written bytes (must be multiple of block size)
|
||||
int32_t qspi_msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize)
|
||||
{
|
||||
int32_t qspi_msc_write_cb(uint32_t lba, uint8_t *buffer, uint32_t bufsize) {
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.printf("QSPI Write block %08x\n", lba);
|
||||
#endif
|
||||
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
|
||||
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
|
||||
return Arcada_QSPI_Flash.writeBlocks(lba, buffer, bufsize/512) ? bufsize : -1;
|
||||
// already include 4K sector caching internally. We don't need to cache it,
|
||||
// yahhhh!!
|
||||
return Arcada_QSPI_Flash.writeBlocks(lba, buffer, bufsize / 512) ? bufsize
|
||||
: -1;
|
||||
}
|
||||
|
||||
// Callback invoked when WRITE10 command is completed (status received and accepted by host).
|
||||
// used to flush any pending cache.
|
||||
void qspi_msc_flush_cb (void)
|
||||
{
|
||||
// Callback invoked when WRITE10 command is completed (status received and
|
||||
// accepted by host). used to flush any pending cache.
|
||||
void qspi_msc_flush_cb(void) {
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.printf("QSPI Flush block\n");
|
||||
#endif
|
||||
|
|
@ -153,37 +185,36 @@ void qspi_msc_flush_cb (void)
|
|||
last_access_ms = millis();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Callback invoked when received READ10 command.
|
||||
// Copy disk's data to buffer (up to bufsize) and
|
||||
// return number of copied bytes (must be multiple of block size)
|
||||
int32_t sd_msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
int32_t sd_msc_read_cb(uint32_t lba, void *buffer, uint32_t bufsize) {
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.printf("SD Read block %08x\n", lba);
|
||||
#endif
|
||||
|
||||
return Arcada_SD_FileSys.card()->readBlocks(lba, (uint8_t*) buffer, bufsize/512) ? bufsize : -1;
|
||||
return Arcada_SD_FileSys.card()->readBlocks(lba, (uint8_t *)buffer,
|
||||
bufsize / 512)
|
||||
? bufsize
|
||||
: -1;
|
||||
}
|
||||
|
||||
// Callback invoked when received WRITE10 command.
|
||||
// Process data in buffer to disk's storage and
|
||||
// Process data in buffer to disk's storage and
|
||||
// return number of written bytes (must be multiple of block size)
|
||||
int32_t sd_msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize)
|
||||
{
|
||||
int32_t sd_msc_write_cb(uint32_t lba, uint8_t *buffer, uint32_t bufsize) {
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.printf("SD Write block %08x\n", lba);
|
||||
#endif
|
||||
|
||||
return Arcada_SD_FileSys.card()->writeBlocks(lba, buffer, bufsize/512) ? bufsize : -1;
|
||||
return Arcada_SD_FileSys.card()->writeBlocks(lba, buffer, bufsize / 512)
|
||||
? bufsize
|
||||
: -1;
|
||||
}
|
||||
|
||||
// Callback invoked when WRITE10 command is completed (status received and accepted by host).
|
||||
// used to flush any pending cache.
|
||||
void sd_msc_flush_cb (void)
|
||||
{
|
||||
// Callback invoked when WRITE10 command is completed (status received and
|
||||
// accepted by host). used to flush any pending cache.
|
||||
void sd_msc_flush_cb(void) {
|
||||
#ifdef ARCADA_MSD_DEBUG
|
||||
Serial.printf("SD Flush block\n");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,24 +1,21 @@
|
|||
#include "Adafruit_Arcada.h"
|
||||
|
||||
|
||||
|
||||
#if defined(__SAMD51__)
|
||||
#define WAV_DAC_BITS 12
|
||||
#define WAV_BUFFER_SIZE 4096
|
||||
#define WAV_DAC_BITS 12
|
||||
#define WAV_BUFFER_SIZE 4096
|
||||
#else
|
||||
#define WAV_DAC_BITS 10
|
||||
#define WAV_BUFFER_SIZE 2048
|
||||
#define WAV_DAC_BITS 10
|
||||
#define WAV_BUFFER_SIZE 2048
|
||||
#endif
|
||||
|
||||
#if defined(ARCADA_LEFT_AUDIO_PIN)
|
||||
#define WAV_STEREO_OUT true
|
||||
#define WAV_STEREO_OUT true
|
||||
#else
|
||||
#define WAV_STEREO_OUT false
|
||||
#define WAV_STEREO_OUT false
|
||||
#endif
|
||||
|
||||
#define SPEAKER_IDLE (1 << (WAV_DAC_BITS - 1))
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Load up a wave file from the filesystem, to prepare for playback
|
||||
|
|
@ -29,7 +26,8 @@
|
|||
wave file samplerate into samplerate pointer
|
||||
*/
|
||||
/**************************************************************************/
|
||||
wavStatus Adafruit_Arcada_SPITFT::WavLoad(char *filename, uint32_t *samplerate) {
|
||||
wavStatus Adafruit_Arcada_SPITFT::WavLoad(char *filename,
|
||||
uint32_t *samplerate) {
|
||||
Serial.printf("Trying: '%s'\n", filename);
|
||||
File wav_file = open(filename, FILE_READ);
|
||||
return WavLoad(wav_file, samplerate);
|
||||
|
|
@ -46,7 +44,7 @@ wavStatus Adafruit_Arcada_SPITFT::WavLoad(char *filename, uint32_t *samplerate)
|
|||
*/
|
||||
/**************************************************************************/
|
||||
wavStatus Adafruit_Arcada_SPITFT::WavLoad(File f, uint32_t *samplerate) {
|
||||
if (! f) {
|
||||
if (!f) {
|
||||
return WAV_ERR_NOFILE;
|
||||
}
|
||||
|
||||
|
|
@ -58,13 +56,13 @@ wavStatus Adafruit_Arcada_SPITFT::WavLoad(File f, uint32_t *samplerate) {
|
|||
analogWriteResolution(WAV_DAC_BITS); // See notes above
|
||||
|
||||
if (!player) {
|
||||
player = new Adafruit_WavePlayer(WAV_STEREO_OUT, WAV_DAC_BITS, WAV_BUFFER_SIZE);
|
||||
player =
|
||||
new Adafruit_WavePlayer(WAV_STEREO_OUT, WAV_DAC_BITS, WAV_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
wavStatus status;
|
||||
status = player->start(_wav_file, samplerate);
|
||||
if((status == WAV_LOAD) || (status == WAV_EOF)) {
|
||||
if ((status == WAV_LOAD) || (status == WAV_EOF)) {
|
||||
// Begin audio playback
|
||||
_wav_playing = true;
|
||||
} else {
|
||||
|
|
@ -98,31 +96,30 @@ wavStatus Adafruit_Arcada_SPITFT::WavReadFile() {
|
|||
@return True if there's free buffer space
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Arcada_SPITFT::WavReadyForData() {
|
||||
return _wav_readflag;
|
||||
}
|
||||
bool Adafruit_Arcada_SPITFT::WavReadyForData() { return _wav_readflag; }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Output the next sample to the DAC(s) - should be called at 'samplerate'!
|
||||
@brief Output the next sample to the DAC(s) - should be called at
|
||||
'samplerate'!
|
||||
@return Status enum from Adafruit WavePlayer library
|
||||
*/
|
||||
/**************************************************************************/
|
||||
wavStatus Adafruit_Arcada_SPITFT::WavPlayNextSample(void) {
|
||||
wavSample sample;
|
||||
|
||||
|
||||
if (!player) {
|
||||
return WAV_EOF;
|
||||
}
|
||||
|
||||
wavStatus status = player->nextSample(&sample);
|
||||
|
||||
if((status == WAV_OK) || (status == WAV_LOAD)) {
|
||||
if ((status == WAV_OK) || (status == WAV_LOAD)) {
|
||||
#if WAV_STEREO_OUT
|
||||
analogWrite(ARCADA_LEFT_AUDIO_PIN , sample.channel0);
|
||||
analogWrite(ARCADA_LEFT_AUDIO_PIN, sample.channel0);
|
||||
analogWrite(ARCADA_RIGHT_AUDIO_PIN, sample.channel1);
|
||||
#else
|
||||
analogWrite(ARCADA_AUDIO_OUT , sample.channel0);
|
||||
analogWrite(ARCADA_AUDIO_OUT, sample.channel0);
|
||||
#endif
|
||||
_wav_playing = true;
|
||||
|
||||
|
|
@ -137,13 +134,67 @@ wavStatus Adafruit_Arcada_SPITFT::WavPlayNextSample(void) {
|
|||
} else if (status == WAV_EOF) {
|
||||
// End of WAV file reached stop audio
|
||||
#if WAV_STEREO_OUT
|
||||
analogWrite(ARCADA_LEFT_AUDIO_PIN , SPEAKER_IDLE);
|
||||
analogWrite(ARCADA_LEFT_AUDIO_PIN, SPEAKER_IDLE);
|
||||
analogWrite(ARCADA_RIGHT_AUDIO_PIN, SPEAKER_IDLE);
|
||||
#else
|
||||
analogWrite(ARCADA_AUDIO_OUT , SPEAKER_IDLE);
|
||||
analogWrite(ARCADA_AUDIO_OUT, SPEAKER_IDLE);
|
||||
#endif
|
||||
_wav_playing = false;
|
||||
} // else WAV_ERR_STALL, do nothing
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Play a wave file completely thru by blocking until end of file
|
||||
@param filename Name of file to open, either relative or abs path
|
||||
@return Status enum from Adafruit WavePlayer library, WAV_OK on success
|
||||
*/
|
||||
/**************************************************************************/
|
||||
wavStatus Adafruit_Arcada_SPITFT::WavPlayComplete(char *filename) {
|
||||
File wav_file = open(filename, FILE_READ);
|
||||
return WavPlayComplete(wav_file);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Play a wave file completely thru by blocking until end of file
|
||||
@param f The already-opened file that we'll play
|
||||
@return Status enum from Adafruit WavePlayer library, WAV_OK on success
|
||||
*/
|
||||
/**************************************************************************/
|
||||
wavStatus Adafruit_Arcada_SPITFT::WavPlayComplete(File f) {
|
||||
wavStatus status;
|
||||
uint32_t sampleRate;
|
||||
|
||||
status = WavLoad(f, &sampleRate);
|
||||
if ((status == WAV_LOAD) || (status == WAV_EOF)) {
|
||||
Serial.println("WAV file loaded!");
|
||||
enableSpeaker(true); // enable speaker output
|
||||
} else {
|
||||
Serial.print("WAV error: ");
|
||||
Serial.println(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
uint32_t t, prior, usec = 1000000L / sampleRate;
|
||||
prior = micros();
|
||||
|
||||
do { // Repeat this loop until WAV_EOF or WAV_ERR_*
|
||||
while ((t = micros()) - prior < usec)
|
||||
;
|
||||
status = WavPlayNextSample();
|
||||
prior = t;
|
||||
|
||||
if (WavReadyForData()) {
|
||||
yield();
|
||||
WavReadFile();
|
||||
}
|
||||
|
||||
yield();
|
||||
} while (status != WAV_EOF);
|
||||
|
||||
enableSpeaker(false); // disable speaker output
|
||||
return WAV_OK;
|
||||
}
|
||||
|
|
|
|||
71
Boards/Adafruit_Arcada_CircuitPlaygroundBluefruit.h
Normal file
71
Boards/Adafruit_Arcada_CircuitPlaygroundBluefruit.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#if defined(ARDUINO_NRF52840_CIRCUITPLAY)
|
||||
#include <Adafruit_CircuitPlayground.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI
|
||||
#define ARCADA_TFT_CS A6 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC A7 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST -1 // Display reset done with chip
|
||||
#define ARCADA_TFT_LITE A3
|
||||
#define ARCADA_TFT_ROTATION 2
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 10
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_SPEAKER_ENABLE 11
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A8
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_CPlay_LIS3DH *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
|
||||
bool variantBegin(void) {
|
||||
CircuitPlayground.begin();
|
||||
accel = new Adafruit_CPlay_LIS3DH(&Wire1);
|
||||
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
uint8_t rtna =
|
||||
0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
tft->sendCommand(0xC6, &rtna, 1);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (CircuitPlayground.leftButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
if (CircuitPlayground.rightButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
76
Boards/Adafruit_Arcada_CircuitPlaygroundExpress.h
Normal file
76
Boards/Adafruit_Arcada_CircuitPlaygroundExpress.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
|
||||
#include <Adafruit_CircuitPlayground.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS A6 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC A7 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST -1 // Display reset done with chip
|
||||
#define ARCADA_TFT_LITE A3
|
||||
#define ARCADA_TFT_ROTATION 2
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 10
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A8
|
||||
|
||||
#define ARCADA_SPIFLASH_CS SS
|
||||
#define ARCADA_SPIFLASH_SPI SPI
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_CPlay_LIS3DH *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
|
||||
bool variantBegin(void) {
|
||||
CircuitPlayground.begin();
|
||||
|
||||
accel = new Adafruit_CPlay_LIS3DH();
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
uint8_t rtna =
|
||||
0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
tft->sendCommand(0xC6, &rtna, 1);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (CircuitPlayground.leftButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
if (CircuitPlayground.rightButton()) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
77
Boards/Adafruit_Arcada_Clue.h
Normal file
77
Boards/Adafruit_Arcada_Clue.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#if defined(ARDUINO_NRF52840_CLUE)
|
||||
#include <Adafruit_LSM6DS33.h>
|
||||
#include <Adafruit_LSM6DS3TRC.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 31 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 32 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 33 // Display reset done with chip
|
||||
#define ARCADA_TFT_LITE 34
|
||||
#define ARCADA_TFT_ROTATION 1
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 18
|
||||
#define ARCADA_NEOPIXEL_NUM 1
|
||||
|
||||
#define ARCADA_AUDIO_OUT 46 // PWM output
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
Adafruit_LSM6DS33 lsm6ds33 = Adafruit_LSM6DS33();
|
||||
Adafruit_LSM6DS3TRC lsm6ds3trc = Adafruit_LSM6DS3TRC();
|
||||
Adafruit_Sensor *accel;
|
||||
|
||||
bool variantBegin(void) {
|
||||
pinMode(5, INPUT_PULLUP);
|
||||
pinMode(11, INPUT_PULLUP);
|
||||
|
||||
if (lsm6ds33.begin_I2C()) {
|
||||
// Serial.println("Found LSM6DS33");
|
||||
accel = lsm6ds33.getAccelerometerSensor();
|
||||
} else if (lsm6ds3trc.begin_I2C()) {
|
||||
// Serial.println("Found LSM6DS3-TRC");
|
||||
accel = lsm6ds3trc.getAccelerometerSensor();
|
||||
} else {
|
||||
// Serial.println("LSM6DS not found");
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel->printSensorDetails();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
uint8_t rtna =
|
||||
0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
tft->sendCommand(0xC6, &rtna, 1);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (!digitalRead(5)) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
if (!digitalRead(11)) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
89
Boards/Adafruit_Arcada_HalloWingM0.h
Normal file
89
Boards/Adafruit_Arcada_HalloWingM0.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#if defined(ADAFRUIT_HALLOWING)
|
||||
#include <Adafruit_FreeTouch.h>
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7735.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI
|
||||
#define ARCADA_TFT_CS 39 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 38 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 37 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 7
|
||||
#define ARCADA_TFT_ROTATION 2
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 128
|
||||
#define ARCADA_TFT_HEIGHT 128
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 4
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A1
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_SPIFLASH_CS SS1
|
||||
#define ARCADA_SPIFLASH_SPI SPI1
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
|
||||
bool variantBegin(void) {
|
||||
accel = new Adafruit_LIS3DH();
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
|
||||
if (!qt_1.begin() || !qt_2.begin() || !qt_3.begin() || !qt_4.begin()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7735 *tft = new Adafruit_ST7735(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->initR(INITR_144GREENTAB);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (qt_4.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
}
|
||||
if (qt_3.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
}
|
||||
if (qt_2.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
if (qt_1.measure() > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
Adafruit_FreeTouch qt_1 =
|
||||
Adafruit_FreeTouch(A2, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
Adafruit_FreeTouch qt_2 =
|
||||
Adafruit_FreeTouch(A3, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
Adafruit_FreeTouch qt_3 =
|
||||
Adafruit_FreeTouch(A4, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
Adafruit_FreeTouch qt_4 =
|
||||
Adafruit_FreeTouch(A5, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
|
||||
};
|
||||
|
||||
#endif
|
||||
102
Boards/Adafruit_Arcada_HalloWingM4.h
Normal file
102
Boards/Adafruit_Arcada_HalloWingM4.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#if defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
|
||||
#include <Adafruit_MSA301.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 0
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_TOUCHOUT_PIN 48
|
||||
#define ARCADA_SPEAKER_ENABLE 49
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 4
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_MSA301 *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
|
||||
bool variantBegin(void) {
|
||||
accel = new Adafruit_MSA301();
|
||||
if (!accel->begin()) { // MSA301 @ 0x26
|
||||
if (!accel->begin(0x62)) { // MSA311 @ 0x62
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
}
|
||||
accel->setPowerMode(MSA301_NORMALMODE);
|
||||
accel->setDataRate(MSA301_DATARATE_1000_HZ);
|
||||
accel->setBandwidth(MSA301_BANDWIDTH_500_HZ);
|
||||
accel->setRange(MSA301_RANGE_4_G);
|
||||
return true;
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 240);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
uint8_t rtna =
|
||||
0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
tft->sendCommand(0xC6, &rtna, 1);
|
||||
tft->setSPISpeed(50000000); // yes fast
|
||||
display = tft;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A2) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
}
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A3) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
}
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A4) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_B;
|
||||
}
|
||||
if (capRead(ARCADA_TOUCHOUT_PIN, A5) > 700) {
|
||||
buttons |= ARCADA_BUTTONMASK_RIGHT | ARCADA_BUTTONMASK_A;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t capRead(uint8_t outpin, uint8_t inpin, uint8_t num_readings = 10) {
|
||||
pinMode(outpin, OUTPUT);
|
||||
pinMode(inpin, INPUT);
|
||||
|
||||
uint16_t counter = 0;
|
||||
for (int r = 0; r < num_readings; r++) {
|
||||
digitalWrite(outpin, HIGH);
|
||||
while (!digitalRead(inpin)) {
|
||||
counter++;
|
||||
if (counter == 65535) {
|
||||
return 0;
|
||||
} // timed out
|
||||
}
|
||||
digitalWrite(outpin, LOW);
|
||||
delay(1);
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
136
Boards/Adafruit_Arcada_MONSTERM4SK.h
Normal file
136
Boards/Adafruit_Arcada_MONSTERM4SK.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI
|
||||
#define ARCADA_TFT_CS 5 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 6 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 4 // Display reset Arduino pin number
|
||||
#define ARCADA_LEFTTFT_SPI SPI1
|
||||
#define ARCADA_LEFTTFT_CS 9 // Display CS Arduino pin number
|
||||
#define ARCADA_LEFTTFT_DC 10 // Display D/C Arduino pin number
|
||||
#define ARCADA_LEFTTFT_RST -1 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 21
|
||||
#define ARCADA_TFT_ROTATION 0
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x0
|
||||
#define ARCADA_TFT_WIDTH 240
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 20
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_LEFT_AUDIO_PIN A0
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define SS_LIGHTSENSOR_PIN 2
|
||||
#define SS_VCCSENSOR_PIN 3
|
||||
#define SS_BACKLIGHT_PIN 5
|
||||
#define SS_TFTRESET_PIN 8
|
||||
#define SS_SWITCH1_PIN 9
|
||||
#define SS_SWITCH2_PIN 10
|
||||
#define SS_SWITCH3_PIN 11
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 3
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC3_Handler
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH *accel = NULL;
|
||||
Adafruit_seesaw ss;
|
||||
Adafruit_ST7789 *display2, *_display; // we need to keep a 'copy' of the
|
||||
// ST7789 version of both displays
|
||||
|
||||
Adafruit_Arcada(){};
|
||||
|
||||
bool variantBegin(void) {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
if (!ss.begin(0x49, -1, false)) {
|
||||
return false;
|
||||
}
|
||||
ss.pinMode(SS_SWITCH1_PIN, INPUT_PULLUP);
|
||||
ss.pinMode(SS_SWITCH2_PIN, INPUT_PULLUP);
|
||||
ss.pinMode(SS_SWITCH3_PIN, INPUT_PULLUP);
|
||||
// reset TFT
|
||||
ss.pinMode(SS_TFTRESET_PIN, OUTPUT);
|
||||
ss.digitalWrite(SS_TFTRESET_PIN, LOW);
|
||||
delay(10);
|
||||
ss.digitalWrite(SS_TFTRESET_PIN, HIGH);
|
||||
delay(10);
|
||||
|
||||
accel = new Adafruit_LIS3DH();
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
_has_accel = false; // couldn't find accelerometer, could be a pybadge LC
|
||||
} else {
|
||||
_has_accel = true;
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void begin(uint32_t freq) {
|
||||
(void)freq;
|
||||
_display->init(240, 240);
|
||||
display2->init(240, 240);
|
||||
}
|
||||
|
||||
void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
display->setAddrWindow(x, y, w, h);
|
||||
}
|
||||
|
||||
void displayBegin(void) {
|
||||
_display = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
display2 = new Adafruit_ST7789(&ARCADA_LEFTTFT_SPI, ARCADA_LEFTTFT_CS,
|
||||
ARCADA_LEFTTFT_DC, ARCADA_LEFTTFT_RST);
|
||||
_display->init(240, 240);
|
||||
display2->init(240, 240);
|
||||
|
||||
uint8_t rtna =
|
||||
0x01; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
|
||||
_display->sendCommand(0xC6, &rtna, 1);
|
||||
display2->sendCommand(0xC6, &rtna, 1);
|
||||
|
||||
_display->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display2->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
_display->setRotation(ARCADA_TFT_ROTATION);
|
||||
display2->setRotation(ARCADA_TFT_ROTATION);
|
||||
_display->setSPISpeed(50000000); // yes fast
|
||||
display2->setSPISpeed(50000000); // 50 MHz!
|
||||
display = _display; // grab the SPITFT pointer for arcada parent
|
||||
}
|
||||
|
||||
uint16_t readLightSensor(void) { return ss.analogRead(SS_LIGHTSENSOR_PIN); }
|
||||
|
||||
float readBatterySensor(void) {
|
||||
return ss.analogRead(SS_VCCSENSOR_PIN) * 2 * 3.3 / 1024;
|
||||
}
|
||||
|
||||
bool setBacklight(uint8_t brightness, bool saveToDisk = false) {
|
||||
// for left tft
|
||||
ss.analogWrite(SS_BACKLIGHT_PIN, brightness);
|
||||
// handle parentally
|
||||
return Adafruit_Arcada_SPITFT::setBacklight(brightness, saveToDisk);
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) {
|
||||
uint32_t buttons = 0;
|
||||
if (!ss.digitalRead(SS_SWITCH1_PIN))
|
||||
buttons |= ARCADA_BUTTONMASK_UP;
|
||||
if (!ss.digitalRead(SS_SWITCH2_PIN))
|
||||
buttons |= ARCADA_BUTTONMASK_A;
|
||||
if (!ss.digitalRead(SS_SWITCH3_PIN))
|
||||
buttons |= ARCADA_BUTTONMASK_DOWN;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
75
Boards/Adafruit_Arcada_PyBadge.h
Normal file
75
Boards/Adafruit_Arcada_PyBadge.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef __ARCADA_PYBADGE_M4__
|
||||
#define __ARCADA_PYBADGE_M4__
|
||||
#if defined(ADAFRUIT_PYBADGE_M4_EXPRESS)
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7735.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 1
|
||||
#define ARCADA_TFT_DEFAULTFILL 0x7BEF
|
||||
#define ARCADA_TFT_WIDTH 160
|
||||
#define ARCADA_TFT_HEIGHT 128
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 51
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 5
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_BUTTON_CLOCK 48
|
||||
#define ARCADA_BUTTON_DATA 49
|
||||
#define ARCADA_BUTTON_LATCH 50
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0x80
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0x40
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0x20
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0x10
|
||||
#define ARCADA_BUTTON_SHIFTMASK_LEFT 0x01
|
||||
#define ARCADA_BUTTON_SHIFTMASK_UP 0x02
|
||||
#define ARCADA_BUTTON_SHIFTMASK_DOWN 0x04
|
||||
#define ARCADA_BUTTON_SHIFTMASK_RIGHT 0x08
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void){};
|
||||
|
||||
bool variantBegin(void) {
|
||||
accel = new Adafruit_LIS3DH();
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
_has_accel = false; // couldn't find accelerometer, could be a pybadge LC
|
||||
} else {
|
||||
_has_accel = true;
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7735 *tft = new Adafruit_ST7735(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->initR(INITR_BLACKTAB);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
72
Boards/Adafruit_Arcada_PyGamer.h
Normal file
72
Boards/Adafruit_Arcada_PyGamer.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#if defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
|
||||
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7735.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 1
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_WIDTH 160
|
||||
#define ARCADA_TFT_HEIGHT 128
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 51
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 5
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_BUTTON_CLOCK 48
|
||||
#define ARCADA_BUTTON_DATA 49
|
||||
#define ARCADA_BUTTON_LATCH 50
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0x80
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0x40
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0x20
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0x10
|
||||
|
||||
#define ARCADA_JOYSTICK_X A11
|
||||
#define ARCADA_JOYSTICK_Y A10
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_SD_CS 4
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
|
||||
bool variantBegin(void) {
|
||||
accel = new Adafruit_LIS3DH();
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7735 *tft = new Adafruit_ST7735(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->initR(INITR_BLACKTAB);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
73
Boards/Adafruit_Arcada_PyGamerAdvance.h
Normal file
73
Boards/Adafruit_Arcada_PyGamerAdvance.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#if defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)
|
||||
|
||||
#include <Adafruit_LIS3DH.h>
|
||||
#include <Adafruit_ST7789.h>
|
||||
|
||||
#define ARCADA_TFT_SPI SPI1
|
||||
#define ARCADA_TFT_CS 44 // Display CS Arduino pin number
|
||||
#define ARCADA_TFT_DC 45 // Display D/C Arduino pin number
|
||||
#define ARCADA_TFT_RST 46 // Display reset Arduino pin number
|
||||
#define ARCADA_TFT_LITE 47
|
||||
#define ARCADA_TFT_ROTATION 3
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_WIDTH 320
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 51
|
||||
#define ARCADA_NEOPIXEL_PIN 8
|
||||
#define ARCADA_NEOPIXEL_NUM 5
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
#define ARCADA_BUTTON_CLOCK 48
|
||||
#define ARCADA_BUTTON_DATA 49
|
||||
#define ARCADA_BUTTON_LATCH 50
|
||||
#define ARCADA_BUTTON_SHIFTMASK_B 0x80
|
||||
#define ARCADA_BUTTON_SHIFTMASK_A 0x40
|
||||
#define ARCADA_BUTTON_SHIFTMASK_START 0x20
|
||||
#define ARCADA_BUTTON_SHIFTMASK_SELECT 0x10
|
||||
|
||||
#define ARCADA_JOYSTICK_X A11
|
||||
#define ARCADA_JOYSTICK_Y A10
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A7
|
||||
#define ARCADA_BATTERY_SENSOR A6
|
||||
|
||||
#define ARCADA_RIGHT_AUDIO_PIN A0
|
||||
#define ARCADA_LEFT_AUDIO_PIN A1
|
||||
|
||||
#define ARCADA_SD_CS 4
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_LIS3DH *accel = NULL;
|
||||
|
||||
Adafruit_Arcada(void) { _has_accel = true; };
|
||||
|
||||
bool variantBegin(void) {
|
||||
accel = new Adafruit_LIS3DH();
|
||||
if (!accel->begin(0x18) && !accel->begin(0x19)) {
|
||||
return false; // couldn't find accelerometer
|
||||
}
|
||||
accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ST7789 *tft = new Adafruit_ST7789(&ARCADA_TFT_SPI, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_DC, ARCADA_TFT_RST);
|
||||
tft->init(240, 320);
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
64
Boards/Adafruit_Arcada_PyPortal.h
Normal file
64
Boards/Adafruit_Arcada_PyPortal.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#if defined(ADAFRUIT_PYPORTAL)
|
||||
#include <Adafruit_ILI9341.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
// 8 bit 320x240 TFT
|
||||
#define ARCADA_TFT_D0 34 // Data bit 0 pin (MUST be on PORT byte boundary)
|
||||
#define ARCADA_TFT_WR 26 // Write-strobe pin (CCL-inverted timer output)
|
||||
#define ARCADA_TFT_DC 10 // Data/command pin
|
||||
#define ARCADA_TFT_CS 11 // Chip-select pin
|
||||
#define ARCADA_TFT_RST 24 // Reset pin
|
||||
#define ARCADA_TFT_RD 9 // Read-strobe pin
|
||||
#define ARCADA_TFT_LITE 25
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_ROTATION 3
|
||||
#define ARCADA_TFT_WIDTH 320
|
||||
#define ARCADA_TFT_HEIGHT 240
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 50
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 2
|
||||
#define ARCADA_NEOPIXEL_NUM 1
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A2
|
||||
|
||||
#define ARCADA_SD_CS 32
|
||||
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_TOUCHSCREEN_YM A6
|
||||
#define ARCADA_TOUCHSCREEN_XP A5
|
||||
#define ARCADA_TOUCHSCREEN_YP A4
|
||||
#define ARCADA_TOUCHSCREEN_XM A7
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MIN 325
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MAX 750
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MIN 840
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MAX 240
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_Arcada(void){};
|
||||
|
||||
bool variantBegin(void) { return true; }
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_ILI9341 *tft = new Adafruit_ILI9341(
|
||||
tft8bitbus, ARCADA_TFT_D0, ARCADA_TFT_WR, ARCADA_TFT_DC, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_RST, ARCADA_TFT_RD);
|
||||
tft->begin();
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
64
Boards/Adafruit_Arcada_PyPortalTitano.h
Normal file
64
Boards/Adafruit_Arcada_PyPortalTitano.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#if defined(ARDUINO_PYPORTAL_M4_TITANO)
|
||||
#include <Adafruit_HX8357.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
// 8 bit 320x240 TFT
|
||||
#define ARCADA_TFT_D0 34 // Data bit 0 pin (MUST be on PORT byte boundary)
|
||||
#define ARCADA_TFT_WR 26 // Write-strobe pin (CCL-inverted timer output)
|
||||
#define ARCADA_TFT_DC 10 // Data/command pin
|
||||
#define ARCADA_TFT_CS 11 // Chip-select pin
|
||||
#define ARCADA_TFT_RST 24 // Reset pin
|
||||
#define ARCADA_TFT_RD 9 // Read-strobe pin
|
||||
#define ARCADA_TFT_LITE 25
|
||||
#define ARCADA_TFT_DEFAULTFILL 0xFFFF
|
||||
#define ARCADA_TFT_ROTATION 3
|
||||
#define ARCADA_TFT_WIDTH 480
|
||||
#define ARCADA_TFT_HEIGHT 320
|
||||
|
||||
#define ARCADA_SPEAKER_ENABLE 50
|
||||
|
||||
#define ARCADA_NEOPIXEL_PIN 2
|
||||
#define ARCADA_NEOPIXEL_NUM 1
|
||||
|
||||
#define ARCADA_LIGHT_SENSOR A2
|
||||
|
||||
#define ARCADA_SD_CS 32
|
||||
|
||||
#define ARCADA_AUDIO_OUT A0
|
||||
|
||||
#define ARCADA_TOUCHSCREEN_YM A6
|
||||
#define ARCADA_TOUCHSCREEN_XP A5
|
||||
#define ARCADA_TOUCHSCREEN_YP A4
|
||||
#define ARCADA_TOUCHSCREEN_XM A7
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MIN 325
|
||||
#define ARCADA_TOUCHSCREEN_CALIBX_MAX 750
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MIN 840
|
||||
#define ARCADA_TOUCHSCREEN_CALIBY_MAX 240
|
||||
|
||||
#define ARCADA_USE_JSON
|
||||
|
||||
#define ARCADA_CALLBACKTIMER 4
|
||||
#define ARCADA_CALLBACKTIMER_HANDLER TC4_Handler
|
||||
|
||||
#include "arcadatype.h"
|
||||
|
||||
class Adafruit_Arcada : public Adafruit_Arcada_SPITFT {
|
||||
public:
|
||||
Adafruit_Arcada(void){};
|
||||
|
||||
bool variantBegin(void) { return true; }
|
||||
|
||||
uint32_t variantReadButtons(void) { return 0; }
|
||||
|
||||
void displayBegin(void) {
|
||||
Adafruit_HX8357 *tft = new Adafruit_HX8357(
|
||||
tft8bitbus, ARCADA_TFT_D0, ARCADA_TFT_WR, ARCADA_TFT_DC, ARCADA_TFT_CS,
|
||||
ARCADA_TFT_RST, ARCADA_TFT_RD);
|
||||
tft->begin();
|
||||
tft->setRotation(ARCADA_TFT_ROTATION);
|
||||
tft->fillScreen(ARCADA_TFT_DEFAULTFILL);
|
||||
display = tft;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
159
arcadatype.h
159
arcadatype.h
|
|
@ -2,33 +2,36 @@
|
|||
#ifndef ARCADATYPE
|
||||
#define ARCADATYPE
|
||||
|
||||
#include <SdFat.h>
|
||||
#include <Adafruit_SPIFlash.h>
|
||||
#include "Adafruit_Arcada_Def.h"
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_ImageReader.h> // Image-reading functions
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <Adafruit_SPIFlash.h>
|
||||
#include <Adafruit_WavePlayer.h>
|
||||
#include <SdFat_Adafruit_Fork.h>
|
||||
#include <TouchScreen.h>
|
||||
|
||||
#if defined(USE_TINYUSB)
|
||||
#include "Adafruit_TinyUSB.h"
|
||||
#include "Adafruit_TinyUSB.h"
|
||||
#endif
|
||||
|
||||
#if defined(ARCADA_USE_JSON)
|
||||
#include <ArduinoJson.h>
|
||||
#include <ArduinoJson.h>
|
||||
#endif
|
||||
|
||||
#define SD_MAX_FILENAME_SIZE 80
|
||||
#define ARCADA_DEFAULT_CONFIGURATION_FILENAME "/arcada_config.json"
|
||||
#define ARCADA_DEFAULT_CONFIGURATION_FILENAME "/arcada_config.json"
|
||||
|
||||
typedef void (*arcada_callback_t)(void);
|
||||
|
||||
/** Filesystems that are currently activated */
|
||||
typedef enum _FilesystemType {
|
||||
ARCADA_FILESYS_NONE,
|
||||
ARCADA_FILESYS_SD,
|
||||
ARCADA_FILESYS_QSPI,
|
||||
ARCADA_FILESYS_SD_AND_QSPI
|
||||
typedef enum _FilesystemType {
|
||||
ARCADA_FILESYS_NONE,
|
||||
ARCADA_FILESYS_SD,
|
||||
ARCADA_FILESYS_QSPI,
|
||||
ARCADA_FILESYS_SD_AND_QSPI
|
||||
} Arcada_FilesystemType;
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief An abstraction class for something with a display, and possibly
|
||||
|
|
@ -38,8 +41,9 @@ typedef enum _FilesystemType {
|
|||
/**************************************************************************/
|
||||
class Adafruit_Arcada_SPITFT {
|
||||
|
||||
public:
|
||||
Adafruit_SPITFT *display = 0; ///< The Adafruit_GFX subclass display which the variant must create
|
||||
public:
|
||||
Adafruit_SPITFT *display =
|
||||
0; ///< The Adafruit_GFX subclass display which the variant must create
|
||||
|
||||
Adafruit_Arcada_SPITFT(void);
|
||||
|
||||
|
|
@ -47,7 +51,8 @@ class Adafruit_Arcada_SPITFT {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Perform any specialized variant setup such as initializing accelerometers, seesaw, etc
|
||||
@brief Perform any specialized variant setup such as initializing
|
||||
accelerometers, seesaw, etc
|
||||
@returns True on variant setup success
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
|
@ -64,7 +69,6 @@ class Adafruit_Arcada_SPITFT {
|
|||
bool timerCallback(float freq, arcada_callback_t callback);
|
||||
float getTimerCallbackFreq(void);
|
||||
|
||||
|
||||
/*! @brief Get the previous callback function we were using
|
||||
@return A pointer to a function that takes no arguments, and returns nothing
|
||||
or NULL on no callback set
|
||||
|
|
@ -76,12 +80,15 @@ class Adafruit_Arcada_SPITFT {
|
|||
void printf(const char *format, ...);
|
||||
|
||||
// Filesystem stuff!
|
||||
Arcada_FilesystemType filesysBegin(Arcada_FilesystemType desiredFilesys=ARCADA_FILESYS_SD_AND_QSPI);
|
||||
int16_t filesysListFiles(const char *path=NULL, const char *extensionFilter=NULL);
|
||||
Arcada_FilesystemType filesysBegin(
|
||||
Arcada_FilesystemType desiredFilesys = ARCADA_FILESYS_SD_AND_QSPI);
|
||||
int16_t filesysListFiles(const char *path = NULL,
|
||||
const char *extensionFilter = NULL);
|
||||
bool chdir(const char *path);
|
||||
File open(const char *path=NULL, uint32_t flags = O_READ);
|
||||
File openFileByIndex(const char *path, uint16_t index,
|
||||
uint32_t flags = O_READ, const char *extensionFilter=NULL);
|
||||
File open(const char *path = NULL, uint32_t flags = O_READ);
|
||||
File openFileByIndex(const char *path, uint16_t index,
|
||||
uint32_t flags = O_READ,
|
||||
const char *extensionFilter = NULL);
|
||||
|
||||
bool exists(const char *path);
|
||||
bool mkdir(const char *path);
|
||||
|
|
@ -89,21 +96,22 @@ class Adafruit_Arcada_SPITFT {
|
|||
uint8_t *writeDataToFlash(uint8_t *data, uint32_t len);
|
||||
uint8_t *writeFileToFlash(const char *filename);
|
||||
uint32_t availableFlash(void);
|
||||
bool filesysBeginMSD(Arcada_FilesystemType desiredFilesys=ARCADA_FILESYS_SD_AND_QSPI);
|
||||
bool filesysBeginMSD(
|
||||
Arcada_FilesystemType desiredFilesys = ARCADA_FILESYS_SD_AND_QSPI);
|
||||
bool recentUSB(uint32_t timeout = 100);
|
||||
bool chooseFile(const char *path, char *filename, uint16_t filename_max,
|
||||
const char *extensionFilter=NULL);
|
||||
bool chooseFile(const char *path, char *filename, uint16_t filename_max,
|
||||
const char *extensionFilter = NULL);
|
||||
|
||||
bool hasControlPad(void);
|
||||
int16_t readJoystickX(uint8_t oversampling=3);
|
||||
int16_t readJoystickY(uint8_t oversampling=3);
|
||||
int16_t readJoystickX(uint8_t oversampling = 3);
|
||||
int16_t readJoystickY(uint8_t oversampling = 3);
|
||||
uint32_t readButtons(void);
|
||||
uint32_t justPressedButtons(void);
|
||||
uint32_t justReleasedButtons(void);
|
||||
|
||||
bool hasTouchscreen(void);
|
||||
void setTouchscreenCalibration(int16_t xmin, int16_t xmax,
|
||||
int16_t ymin, int16_t ymax);
|
||||
void setTouchscreenCalibration(int16_t xmin, int16_t xmax, int16_t ymin,
|
||||
int16_t ymax);
|
||||
TSPoint getTouchscreenPoint(void);
|
||||
|
||||
uint16_t readLightSensor(void);
|
||||
|
|
@ -130,32 +138,39 @@ class Adafruit_Arcada_SPITFT {
|
|||
*/
|
||||
/************************************************************************/
|
||||
uint16_t *getFrameBuffer(void) {
|
||||
return _canvas ? _canvas->getBuffer() : NULL; }
|
||||
bool blitFrameBuffer(uint16_t x, uint16_t y,
|
||||
bool blocking=false, bool bigEndian=false, Adafruit_SPITFT *display=NULL);
|
||||
return _canvas ? _canvas->getBuffer() : NULL;
|
||||
}
|
||||
bool blitFrameBuffer(uint16_t x, uint16_t y, bool blocking = false,
|
||||
bool bigEndian = false, Adafruit_SPITFT *display = NULL);
|
||||
uint16_t ColorHSV565(int16_t H, uint8_t S, uint8_t V);
|
||||
|
||||
bool setBacklight(uint8_t brightness, bool saveToDisk=false);
|
||||
bool setBacklight(uint8_t brightness, bool saveToDisk = false);
|
||||
uint8_t getBacklight(void);
|
||||
bool setVolume(uint8_t volume, bool saveToDisk=false);
|
||||
bool setVolume(uint8_t volume, bool saveToDisk = false);
|
||||
uint8_t getVolume(void);
|
||||
void enableSpeaker(bool flag);
|
||||
|
||||
// Alerts
|
||||
void alertBox(const char *string, uint16_t boxColor, uint16_t textColor,
|
||||
uint32_t continueButtonMask);
|
||||
void infoBox(const char *string, uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
|
||||
void warnBox(const char *string, uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
|
||||
void errorBox(const char *string, uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
|
||||
uint32_t continueButtonMask);
|
||||
void infoBox(const char *string,
|
||||
uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
|
||||
void warnBox(const char *string,
|
||||
uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
|
||||
void errorBox(const char *string,
|
||||
uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
|
||||
void haltBox(const char *string);
|
||||
uint8_t menu(const char **menu_strings, uint8_t menu_num,
|
||||
uint16_t boxColor, uint16_t textColor, bool cancellable = false);
|
||||
uint8_t menu(const char **menu_strings, uint8_t menu_num, uint16_t boxColor,
|
||||
uint16_t textColor, bool cancellable = false);
|
||||
|
||||
// Configuration JSON files
|
||||
bool loadConfigurationFile(const char *filename = ARCADA_DEFAULT_CONFIGURATION_FILENAME);
|
||||
bool saveConfigurationFile(const char *filename = ARCADA_DEFAULT_CONFIGURATION_FILENAME);
|
||||
bool loadConfigurationFile(
|
||||
const char *filename = ARCADA_DEFAULT_CONFIGURATION_FILENAME);
|
||||
bool saveConfigurationFile(
|
||||
const char *filename = ARCADA_DEFAULT_CONFIGURATION_FILENAME);
|
||||
|
||||
Adafruit_NeoPixel pixels; ///< The neopixel strip, of length ARCADA_NEOPIXEL_NUM
|
||||
Adafruit_NeoPixel
|
||||
pixels; ///< The neopixel strip, of length ARCADA_NEOPIXEL_NUM
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -175,10 +190,13 @@ class Adafruit_Arcada_SPITFT {
|
|||
bool hasWiFi(void) { return _has_wifi; }
|
||||
|
||||
#ifdef ARCADA_USE_JSON
|
||||
StaticJsonDocument<256> configJSON; ///< The object to store our various settings, you need to restore/save this with (load/save)ConfigurationFile
|
||||
StaticJsonDocument<256>
|
||||
configJSON; ///< The object to store our various settings, you need to
|
||||
///< restore/save this with (load/save)ConfigurationFile
|
||||
#endif
|
||||
|
||||
ImageReturnCode drawBMP(char *filename, int16_t x, int16_t y, Adafruit_SPITFT *tft=0x0, boolean transact = true);
|
||||
ImageReturnCode drawBMP(char *filename, int16_t x, int16_t y,
|
||||
Adafruit_SPITFT *tft = 0x0, boolean transact = true);
|
||||
Adafruit_ImageReader *getImageReader(void);
|
||||
|
||||
wavStatus WavLoad(char *filename, uint32_t *samplerate);
|
||||
|
|
@ -186,19 +204,29 @@ class Adafruit_Arcada_SPITFT {
|
|||
wavStatus WavReadFile();
|
||||
wavStatus WavPlayNextSample(void);
|
||||
bool WavReadyForData();
|
||||
wavStatus WavPlayComplete(char *filename);
|
||||
wavStatus WavPlayComplete(File f);
|
||||
|
||||
protected:
|
||||
bool _has_accel = false; ///< Internally tracked variable if accelerometer was found
|
||||
bool _has_wifi = false; ///< Internally tracked variable if wifi module was found
|
||||
Adafruit_ImageReader *QSPI_imagereader = 0, ///< If initalized, the imagereader for the QSPI filesystem
|
||||
*SD_imagereader = 0; ///< If initalized, the imagereader for the SD card filesystem
|
||||
protected:
|
||||
bool _has_accel =
|
||||
false; ///< Internally tracked variable if accelerometer was found
|
||||
bool _has_wifi =
|
||||
false; ///< Internally tracked variable if wifi module was found
|
||||
Adafruit_ImageReader
|
||||
*QSPI_imagereader =
|
||||
0, ///< If initalized, the imagereader for the QSPI filesystem
|
||||
*SD_imagereader =
|
||||
0; ///< If initalized, the imagereader for the SD card filesystem
|
||||
|
||||
|
||||
private:
|
||||
uint32_t last_buttons, ///< After readButtons() is called, this has the previous button states
|
||||
curr_buttons, ///< After readButtons() is called, this has the current button states
|
||||
justpressed_buttons, ///< After readButtons() is called, this has what buttons were pressed since the call
|
||||
justreleased_buttons; ///< After readButtons() is called, this has what buttons were released since the call
|
||||
private:
|
||||
uint32_t last_buttons, ///< After readButtons() is called, this has the
|
||||
///< previous button states
|
||||
curr_buttons, ///< After readButtons() is called, this has the current
|
||||
///< button states
|
||||
justpressed_buttons, ///< After readButtons() is called, this has what
|
||||
///< buttons were pressed since the call
|
||||
justreleased_buttons; ///< After readButtons() is called, this has what
|
||||
///< buttons were released since the call
|
||||
|
||||
void _initAlertFonts(void);
|
||||
|
||||
|
|
@ -208,7 +236,8 @@ class Adafruit_Arcada_SPITFT {
|
|||
Arcada_FilesystemType _filesys_type = ARCADA_FILESYS_NONE;
|
||||
char _cwd_path[255];
|
||||
|
||||
GFXcanvas16 *_canvas = NULL; bool _first_frame = true;
|
||||
GFXcanvas16 *_canvas = NULL;
|
||||
bool _first_frame = true;
|
||||
|
||||
uint8_t _volume = 255, _brightness = 255;
|
||||
|
||||
|
|
@ -222,19 +251,15 @@ class Adafruit_Arcada_SPITFT {
|
|||
|
||||
float _callback_freq = 0;
|
||||
arcada_callback_t _callback_func = NULL;
|
||||
|
||||
// Pins
|
||||
int8_t _sd_cs, _speaker_en, _neopixel_pin, _backlight_pin,
|
||||
_touch_xp, _touch_yp, _touch_xm, _touch_ym,
|
||||
_start_button = -1, _select_button, _a_button, _b_button,
|
||||
_up_button, _down_button, _left_button, _right_button,
|
||||
_button_latch, _button_clock, _button_data,
|
||||
_battery_sensor, _light_sensor, _joystick_x, _joystick_y;
|
||||
uint8_t _neopixel_num = 0,
|
||||
_shift_up, _shift_down, _shift_left, _shift_right,
|
||||
_shift_a, _shift_b, _shift_select, _shift_start;
|
||||
|
||||
// Pins
|
||||
int8_t _sd_cs, _speaker_en, _neopixel_pin, _backlight_pin, _touch_xp,
|
||||
_touch_yp, _touch_xm, _touch_ym,
|
||||
_start_button = -1, _select_button, _a_button, _b_button, _up_button,
|
||||
_down_button, _left_button, _right_button, _button_latch, _button_clock,
|
||||
_button_data, _battery_sensor, _light_sensor, _joystick_x, _joystick_y;
|
||||
uint8_t _neopixel_num = 0, _shift_up, _shift_down, _shift_left, _shift_right,
|
||||
_shift_a, _shift_b, _shift_select, _shift_start;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ void setup() {
|
|||
//while (!Serial) delay(10);
|
||||
Serial.print("Hello! Arcada Callback Test");
|
||||
|
||||
uint8_t i =0;
|
||||
|
||||
// Start TFT and fill black
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
|
|
|
|||
153
examples/arcada_plotter/arcada_plotter.ino
Normal file
153
examples/arcada_plotter/arcada_plotter.ino
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
#include <CircularBuffer.h>
|
||||
|
||||
Adafruit_Arcada arcada;
|
||||
|
||||
// Color definitions
|
||||
#define BACKGROUND_COLOR __builtin_bswap16(ARCADA_BLACK)
|
||||
#define BORDER_COLOR __builtin_bswap16(ARCADA_BLUE)
|
||||
#define PLOT_COLOR_1 __builtin_bswap16(ARCADA_YELLOW)
|
||||
#define TITLE_COLOR __builtin_bswap16(ARCADA_WHITE)
|
||||
#define TICKTEXT_COLOR __builtin_bswap16(ARCADA_WHITE)
|
||||
#define TICKLINE_COLOR __builtin_bswap16(ARCADA_DARKGREY)
|
||||
|
||||
// Buffers surrounding the plot area
|
||||
#define PLOT_TOPBUFFER 20
|
||||
#define PLOT_LEFTBUFFER 40
|
||||
#define PLOT_BOTTOMBUFFER 20
|
||||
#define PLOT_W (ARCADA_TFT_WIDTH - PLOT_LEFTBUFFER)
|
||||
#define PLOT_H (ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER - PLOT_TOPBUFFER)
|
||||
|
||||
// Which pin to plot
|
||||
#define ANALOG_INPUT A2
|
||||
// millisecond delay between samples (min 50 for CLUE)
|
||||
#define DELAY_PER_SAMPLE 50
|
||||
|
||||
// Buffer for our plot data
|
||||
CircularBuffer<float, PLOT_W> data_buffer;
|
||||
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
Serial.print("Hello! Arcada Plotter");
|
||||
|
||||
// Start TFT and fill black
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
while (1) delay(10);
|
||||
}
|
||||
arcada.displayBegin();
|
||||
|
||||
// Turn on backlight
|
||||
arcada.setBacklight(255);
|
||||
|
||||
if (! arcada.createFrameBuffer(ARCADA_TFT_WIDTH, ARCADA_TFT_HEIGHT)) {
|
||||
Serial.print("Failed to allocate framebuffer");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t timestamp = 0;
|
||||
void loop() {
|
||||
if (millis() - timestamp < DELAY_PER_SAMPLE) {
|
||||
return;
|
||||
}
|
||||
timestamp = millis();
|
||||
int reading = analogRead(ANALOG_INPUT);
|
||||
data_buffer.push(reading);
|
||||
plotBuffer(arcada.getCanvas(), data_buffer, "Analog Input");
|
||||
arcada.blitFrameBuffer(0, 0, false, true);
|
||||
Serial.print("Drew in ");
|
||||
Serial.print(millis()-timestamp);
|
||||
Serial.println(" ms");
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
|
||||
|
||||
void plotBuffer(GFXcanvas16 *_canvas, CircularBuffer<float, PLOT_W> &buffer, const char *title) {
|
||||
_canvas->fillScreen(BACKGROUND_COLOR);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER-1, PLOT_TOPBUFFER,
|
||||
PLOT_LEFTBUFFER-1, PLOT_H+PLOT_TOPBUFFER, BORDER_COLOR);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER-1, PLOT_TOPBUFFER+PLOT_H+1,
|
||||
ARCADA_TFT_WIDTH, PLOT_TOPBUFFER+PLOT_H+1, BORDER_COLOR);
|
||||
_canvas->setTextSize(2);
|
||||
_canvas->setTextColor(TITLE_COLOR);
|
||||
uint16_t title_len = strlen(title) * 12;
|
||||
_canvas->setCursor((_canvas->width()-title_len)/2, 0);
|
||||
_canvas->print(title);
|
||||
|
||||
float minY = 0;
|
||||
float maxY = 0;
|
||||
|
||||
if (buffer.size() > 0) {
|
||||
maxY = minY = buffer[0];
|
||||
}
|
||||
for (int i=0; i< buffer.size(); i++) {
|
||||
minY = min(minY, buffer[i]);
|
||||
maxY = max(maxY, buffer[i]);
|
||||
}
|
||||
//Serial.printf("Data range: %f ~ %f\n", minY, maxY);
|
||||
|
||||
float MIN_DELTA = 10.0;
|
||||
if (maxY - minY < MIN_DELTA) {
|
||||
float mid = (maxY + minY) / 2;
|
||||
maxY = mid + MIN_DELTA / 2;
|
||||
minY = mid - MIN_DELTA / 2;
|
||||
} else {
|
||||
float extra = (maxY - minY) / 10;
|
||||
maxY += extra;
|
||||
minY -= extra;
|
||||
}
|
||||
//Serial.printf("Y range: %f ~ %f\n", minY, maxY);
|
||||
|
||||
printTicks(_canvas, 5, minY, maxY);
|
||||
|
||||
int16_t last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer.size(); i++) {
|
||||
int16_t y = map(buffer[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
|
||||
//Serial.printf("%0.1f -> %d, ", cbuffer[i], y);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
//y = TFT_H - y + PLOT_BOTTOMBUFFER - PLOT_TOPBUFFER;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_1);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void printTicks(GFXcanvas16 *_canvas, uint8_t ticks, float minY, float maxY) {
|
||||
_canvas->setTextSize(1);
|
||||
_canvas->setTextColor(TICKTEXT_COLOR);
|
||||
// Draw ticks
|
||||
for (int t=0; t<ticks; t++) {
|
||||
float v = map(t, 0, ticks-1, minY, maxY);
|
||||
uint16_t y = map(t, 0, ticks-1, ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER - 4, PLOT_TOPBUFFER);
|
||||
printLabel(_canvas, 0, y, v);
|
||||
uint16_t line_y = map(t, 0, ticks-1, ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER, PLOT_TOPBUFFER);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER, line_y, ARCADA_TFT_WIDTH, line_y, TICKLINE_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
void printLabel(GFXcanvas16 *_canvas, uint16_t x, uint16_t y, float val) {
|
||||
(void) x;
|
||||
|
||||
char label[20];
|
||||
if (abs(val) < 1) {
|
||||
snprintf(label, 19, "%0.2f", val);
|
||||
} else if (abs(val) < 10) {
|
||||
snprintf(label, 19, "%0.1f", val);
|
||||
} else {
|
||||
snprintf(label, 19, "%d", (int)val);
|
||||
}
|
||||
|
||||
_canvas->setCursor(PLOT_LEFTBUFFER-strlen(label)*6-5, y);
|
||||
_canvas->print(label);
|
||||
}
|
||||
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
Adafruit_Arcada arcada;
|
||||
char *wavPath = "/wavs";
|
||||
const char *wavPath = "/wavs";
|
||||
volatile bool playing = false;
|
||||
|
||||
// Crude error handler. Prints message to Serial Monitor, blinks LED.
|
||||
|
|
@ -86,4 +86,4 @@ void wavOutCallback(void) {
|
|||
} else {
|
||||
playing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,567 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
#include <CircularBuffer.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_LSM6DS33.h>
|
||||
#include <Adafruit_LIS3MDL.h>
|
||||
#include <Adafruit_SHT31.h>
|
||||
#include <Adafruit_APDS9960.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include "Adafruit_NeoPixel.h"
|
||||
#include <PDM.h>
|
||||
#include "digikey_logo.h"
|
||||
#include "coin.h"
|
||||
|
||||
Adafruit_Arcada arcada;
|
||||
Adafruit_LSM6DS33 lsm6ds33;
|
||||
Adafruit_LIS3MDL lis3mdl;
|
||||
Adafruit_SHT31 sht30;
|
||||
Adafruit_APDS9960 apds9960;
|
||||
Adafruit_BMP280 bmp280;
|
||||
extern PDMClass PDM;
|
||||
#define WHITE_LED 43
|
||||
Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, 18, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
// Color definitions
|
||||
#define BACKGROUND_COLOR __builtin_bswap16(ARCADA_BLACK)
|
||||
#define BORDER_COLOR __builtin_bswap16(ARCADA_BLUE)
|
||||
#define PLOT_COLOR_1 __builtin_bswap16(ARCADA_PINK)
|
||||
#define PLOT_COLOR_2 __builtin_bswap16(ARCADA_GREENYELLOW)
|
||||
#define PLOT_COLOR_3 __builtin_bswap16(ARCADA_CYAN)
|
||||
#define TITLE_COLOR __builtin_bswap16(ARCADA_WHITE)
|
||||
#define TICKTEXT_COLOR __builtin_bswap16(ARCADA_WHITE)
|
||||
#define TICKLINE_COLOR __builtin_bswap16(ARCADA_DARKGREY)
|
||||
|
||||
// Buffers surrounding the plot area
|
||||
#define PLOT_TOPBUFFER 20
|
||||
#define PLOT_LEFTBUFFER 40
|
||||
#define PLOT_BOTTOMBUFFER 20
|
||||
#define PLOT_W (ARCADA_TFT_WIDTH - PLOT_LEFTBUFFER)
|
||||
#define PLOT_H (ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER - PLOT_TOPBUFFER)
|
||||
|
||||
// millisecond delay between samples
|
||||
uint16_t DELAY_PER_SAMPLE = 50;
|
||||
#define NUM_SAMPLERATES 16
|
||||
uint16_t samplerates[NUM_SAMPLERATES] = {50, 100, 250, 500, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000};
|
||||
bool rate_mode = false;
|
||||
|
||||
void plotBuffer(GFXcanvas16 *_canvas, const char *title,
|
||||
CircularBuffer<float, PLOT_W> &buffer1,
|
||||
CircularBuffer<float, PLOT_W> &buffer2,
|
||||
CircularBuffer<float, PLOT_W> &buffer3);
|
||||
|
||||
// Buffer for our plot data
|
||||
CircularBuffer<float, PLOT_W> data_buffer;
|
||||
CircularBuffer<float, PLOT_W> data_buffer2;
|
||||
CircularBuffer<float, PLOT_W> data_buffer3;
|
||||
|
||||
typedef enum _modes {
|
||||
MODE_SPIRITLEVEL,
|
||||
MODE_TEMPPLOT,
|
||||
MODE_PRESPLOT,
|
||||
MODE_HUMPLOT,
|
||||
MODE_LITEPLOT,
|
||||
MODE_RGBPLOT,
|
||||
MODE_PROXPLOT,
|
||||
MODE_PULSEPLOT,
|
||||
MODE_MICPLOT,
|
||||
MODE_ACCPLOT,
|
||||
MODE_GYROPLOT,
|
||||
MODE_MAGPLOT
|
||||
} demo_modes;
|
||||
|
||||
demo_modes mode = MODE_SPIRITLEVEL;
|
||||
demo_modes last_mode = MODE_MAGPLOT;
|
||||
void start_level();
|
||||
void draw_level();
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
Serial.print("Hello! Arcada CLUE sensor plotter");
|
||||
//while (!Serial) yield();
|
||||
|
||||
// Start TFT and fill black
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
while (1) delay(10);
|
||||
}
|
||||
arcada.displayBegin();
|
||||
pixel.begin();
|
||||
|
||||
if (! arcada.createFrameBuffer(ARCADA_TFT_WIDTH, ARCADA_TFT_HEIGHT)) {
|
||||
Serial.print("Failed to allocate framebuffer");
|
||||
while (1);
|
||||
}
|
||||
|
||||
GFXcanvas16 *canvas = arcada.getCanvas();
|
||||
uint16_t *buffer = canvas->getBuffer();
|
||||
for (int h=0; h<240; h++) {
|
||||
for (int w=0; w<DIGIKEY_LOGO_HEIGHT; w++) {
|
||||
buffer[h*DIGIKEY_LOGO_HEIGHT + w] = digikey_logo[h*DIGIKEY_LOGO_HEIGHT + w];
|
||||
}
|
||||
}
|
||||
arcada.blitFrameBuffer(0, 0);
|
||||
|
||||
// Turn on backlight
|
||||
for (int i=0; i<=255; i++) {
|
||||
arcada.setBacklight(i);
|
||||
delay(2);
|
||||
}
|
||||
|
||||
uint32_t usec = 1000000L / SAMPLE_RATE, last_millis = millis();
|
||||
uint8_t pixidx=0;
|
||||
analogWriteResolution(8);
|
||||
for (uint32_t i=0; i<sizeof(coinaudio); i++) {
|
||||
delayMicroseconds(usec);
|
||||
analogWrite(46, (uint16_t)coinaudio[i]);
|
||||
if ( millis() - last_millis > 10) {
|
||||
pixel.setPixelColor(0, Wheel(pixidx++));
|
||||
pixel.show();
|
||||
last_millis = millis();
|
||||
}
|
||||
}
|
||||
|
||||
// light up while logoing
|
||||
for (int i=0; i<1000; i+=10) {
|
||||
pixel.setPixelColor(0, Wheel(pixidx++));
|
||||
pixel.show();
|
||||
delay(10);
|
||||
}
|
||||
|
||||
// Turn off backlight
|
||||
for (int i=255; i>=0; i--) {
|
||||
arcada.setBacklight(i);
|
||||
delay(2);
|
||||
}
|
||||
arcada.display->fillScreen(0);
|
||||
pixel.setPixelColor(0, 0);
|
||||
pixel.show();
|
||||
|
||||
if (!apds9960.begin() || !lsm6ds33.begin_I2C() || !lis3mdl.begin_I2C() ||
|
||||
!sht30.begin(0x44) || !bmp280.begin()) {
|
||||
Serial.println("Failed to find CLUE sensors!");
|
||||
arcada.haltBox("Failed to init CLUE sensors");
|
||||
}
|
||||
/********** Check MIC */
|
||||
PDM.onReceive(onPDMdata);
|
||||
if (!PDM.begin(1, 16000)) {
|
||||
Serial.println("**Failed to start PDM!");
|
||||
}
|
||||
|
||||
data_buffer.clear();
|
||||
data_buffer2.clear();
|
||||
data_buffer3.clear();
|
||||
pinMode(WHITE_LED, OUTPUT);
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
|
||||
uint32_t timestamp = 0;
|
||||
|
||||
void loop() {
|
||||
timestamp = millis();
|
||||
|
||||
if (mode == MODE_SPIRITLEVEL) {
|
||||
if (last_mode != MODE_SPIRITLEVEL) {
|
||||
start_level();
|
||||
arcada.setBacklight(255);
|
||||
}
|
||||
draw_level();
|
||||
}
|
||||
else if (mode == MODE_TEMPPLOT) {
|
||||
float t = bmp280.readTemperature();
|
||||
data_buffer.push(t);
|
||||
Serial.printf("Temp: %f\n", t);
|
||||
plotBuffer(arcada.getCanvas(), "Temperature (C)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_PRESPLOT) {
|
||||
float p = bmp280.readPressure();
|
||||
data_buffer.push(p);
|
||||
Serial.printf("Pressure: %f Pa\n", p);
|
||||
plotBuffer(arcada.getCanvas(), "Pressure (Pa)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_HUMPLOT) {
|
||||
float h = sht30.readHumidity();
|
||||
data_buffer.push(h);
|
||||
Serial.printf("Humid: %f %\n", h);
|
||||
plotBuffer(arcada.getCanvas(),"Humidity (%)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_LITEPLOT) {
|
||||
uint16_t r, g, b, c;
|
||||
apds9960.enableColor(true);
|
||||
//wait for color data to be ready
|
||||
while(! apds9960.colorDataReady()) {
|
||||
delay(5);
|
||||
}
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
data_buffer.push(c);
|
||||
Serial.printf("Light: %d\n", c);
|
||||
plotBuffer(arcada.getCanvas(),"Light",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_RGBPLOT) {
|
||||
uint16_t r, g, b, c;
|
||||
digitalWrite(WHITE_LED, HIGH);
|
||||
apds9960.enableColor(true);
|
||||
//wait for color data to be ready
|
||||
while(! apds9960.colorDataReady()) {
|
||||
delay(5);
|
||||
}
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
data_buffer.push(r);
|
||||
data_buffer2.push(g);
|
||||
data_buffer3.push(b);
|
||||
Serial.printf("Color: %d %d %d\n", r, g, b);
|
||||
plotBuffer(arcada.getCanvas(),"Color (RGB)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_PROXPLOT) {
|
||||
apds9960.enableProximity(true);
|
||||
uint16_t p = apds9960.readProximity();
|
||||
data_buffer.push(p);
|
||||
Serial.printf("Proximity: %d\n", p);
|
||||
plotBuffer(arcada.getCanvas(),"Proximity",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_PULSEPLOT){
|
||||
uint16_t r, g, b, c;
|
||||
apds9960.enableProximity(true);
|
||||
uint16_t p = apds9960.readProximity();
|
||||
if (p < 200) {
|
||||
// turn off LED and leave
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
} else {
|
||||
digitalWrite(WHITE_LED, HIGH);
|
||||
apds9960.enableColor(true);
|
||||
apds9960.setADCIntegrationTime(3);
|
||||
apds9960.setADCGain(APDS9960_AGAIN_64X);
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
data_buffer.push(c);
|
||||
Serial.printf("Pulse: %d\n", c);
|
||||
}
|
||||
plotBuffer(arcada.getCanvas(),"Pulse",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_MICPLOT) {
|
||||
uint32_t pdm_vol = getPDMwave(256);
|
||||
data_buffer.push(pdm_vol);
|
||||
Serial.print("PDM volume: "); Serial.println(pdm_vol);
|
||||
plotBuffer(arcada.getCanvas(), "Mic Volume",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_ACCPLOT) {
|
||||
sensors_event_t accel;
|
||||
lsm6ds33.getEvent(&accel, NULL, NULL);
|
||||
float x = accel.acceleration.x;
|
||||
float y = accel.acceleration.y;
|
||||
float z = accel.acceleration.z;
|
||||
data_buffer.push(x);
|
||||
data_buffer2.push(y);
|
||||
data_buffer3.push(z);
|
||||
Serial.printf("Accel: %f %f %f\n", x, y, z);
|
||||
plotBuffer(arcada.getCanvas(), "Accel (m/s^2)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_GYROPLOT) {
|
||||
sensors_event_t gyro;
|
||||
lsm6ds33.getEvent(NULL, &gyro, NULL);
|
||||
float x = gyro.gyro.x * SENSORS_RADS_TO_DPS;
|
||||
float y = gyro.gyro.y * SENSORS_RADS_TO_DPS;
|
||||
float z = gyro.gyro.z * SENSORS_RADS_TO_DPS;
|
||||
data_buffer.push(x);
|
||||
data_buffer2.push(y);
|
||||
data_buffer3.push(z);
|
||||
Serial.printf("Gyro: %f %f %f\n", x, y, z);
|
||||
plotBuffer(arcada.getCanvas(), "Gyro (dps)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (mode == MODE_MAGPLOT) {
|
||||
sensors_event_t mag;
|
||||
lis3mdl.getEvent(&mag);
|
||||
float x = mag.magnetic.x;
|
||||
float y = mag.magnetic.y;
|
||||
float z = mag.magnetic.z;
|
||||
data_buffer.push(x);
|
||||
data_buffer2.push(y);
|
||||
data_buffer3.push(z);
|
||||
Serial.printf("Mag: %f %f %f\n", x, y, z);
|
||||
plotBuffer(arcada.getCanvas(), "Mag (uT)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else {
|
||||
data_buffer.clear();
|
||||
mode = MODE_TEMPPLOT;
|
||||
return;
|
||||
}
|
||||
|
||||
arcada.blitFrameBuffer(0, 0, false, true);
|
||||
//uint16_t drawtime = millis()-timestamp;
|
||||
//Serial.printf("Drew in %d ms\n", drawtime);
|
||||
last_mode = mode;
|
||||
|
||||
// bool left_held = false, right_held = false;
|
||||
do {
|
||||
uint8_t buttons = arcada.readButtons();
|
||||
uint8_t justPressed = arcada.justPressedButtons();
|
||||
uint8_t justReleased = arcada.justReleasedButtons();
|
||||
|
||||
//Serial.printf("Buttons %x, Rate mode %d\n", buttons, rate_mode);
|
||||
|
||||
if (!rate_mode && (justReleased & ARCADA_BUTTONMASK_LEFT)) {
|
||||
int m = (int)mode - 1;
|
||||
if (m < 0) {
|
||||
m = MODE_MAGPLOT;
|
||||
}
|
||||
mode = (demo_modes)m;
|
||||
data_buffer.clear();
|
||||
data_buffer2.clear();
|
||||
data_buffer3.clear();
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
// only right button pressed
|
||||
if (!rate_mode && (justReleased & ARCADA_BUTTONMASK_RIGHT)) {
|
||||
int m = (int)mode + 1;
|
||||
if (m > MODE_MAGPLOT) {
|
||||
m = 0;
|
||||
}
|
||||
mode = (demo_modes)m;
|
||||
data_buffer.clear();
|
||||
data_buffer2.clear();
|
||||
data_buffer3.clear();
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
|
||||
|
||||
if (! (buttons & (ARCADA_BUTTONMASK_LEFT | ARCADA_BUTTONMASK_RIGHT))) {
|
||||
rate_mode = false;
|
||||
}
|
||||
|
||||
// right button held down, left button released
|
||||
if ((buttons & ARCADA_BUTTONMASK_RIGHT) && (justPressed & ARCADA_BUTTONMASK_LEFT)) {
|
||||
rate_mode = true;
|
||||
uint8_t i;
|
||||
for (i=0; i < NUM_SAMPLERATES; i++) {
|
||||
if (DELAY_PER_SAMPLE == samplerates[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
// special case, cant go faster
|
||||
DELAY_PER_SAMPLE = samplerates[i];
|
||||
} else if (i >= NUM_SAMPLERATES-1) {
|
||||
// special case, something went wrong
|
||||
DELAY_PER_SAMPLE = samplerates[NUM_SAMPLERATES-1];
|
||||
} else {
|
||||
DELAY_PER_SAMPLE = samplerates[i-1];
|
||||
}
|
||||
Serial.printf("Delaying %d ms per sample\n", DELAY_PER_SAMPLE);
|
||||
// immediately redraw
|
||||
break;
|
||||
}
|
||||
// left button held down, right button released
|
||||
if ((buttons & ARCADA_BUTTONMASK_LEFT) && (justPressed & ARCADA_BUTTONMASK_RIGHT)) {
|
||||
rate_mode = true;
|
||||
uint8_t i;
|
||||
for (i=0; i < NUM_SAMPLERATES; i++) {
|
||||
if (DELAY_PER_SAMPLE == samplerates[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= (NUM_SAMPLERATES-1)) {
|
||||
// special case, cant go slower
|
||||
DELAY_PER_SAMPLE = samplerates[NUM_SAMPLERATES-1];
|
||||
} else {
|
||||
DELAY_PER_SAMPLE = samplerates[i+1];
|
||||
}
|
||||
Serial.printf("Delaying %d ms per sample\n", DELAY_PER_SAMPLE);
|
||||
// immediately redraw
|
||||
break;
|
||||
}
|
||||
int time_remaining = DELAY_PER_SAMPLE - (millis()-timestamp);
|
||||
if (time_remaining > 0) {
|
||||
delay(min(10, time_remaining));
|
||||
}
|
||||
} while (DELAY_PER_SAMPLE > (millis()-timestamp));
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
|
||||
|
||||
void plotBuffer(GFXcanvas16 *_canvas, const char *title,
|
||||
CircularBuffer<float, PLOT_W> &buffer1,
|
||||
CircularBuffer<float, PLOT_W> &buffer2,
|
||||
CircularBuffer<float, PLOT_W> &buffer3) {
|
||||
_canvas->fillScreen(BACKGROUND_COLOR);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER-1, PLOT_TOPBUFFER,
|
||||
PLOT_LEFTBUFFER-1, PLOT_H+PLOT_TOPBUFFER, BORDER_COLOR);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER-1, PLOT_TOPBUFFER+PLOT_H+1,
|
||||
ARCADA_TFT_WIDTH, PLOT_TOPBUFFER+PLOT_H+1, BORDER_COLOR);
|
||||
_canvas->setTextSize(2);
|
||||
_canvas->setTextColor(TITLE_COLOR);
|
||||
uint16_t title_len = strlen(title) * 12;
|
||||
_canvas->setCursor((_canvas->width()-title_len)/2, 0);
|
||||
_canvas->print(title);
|
||||
|
||||
float minY = 0;
|
||||
float maxY = 0;
|
||||
|
||||
if (buffer1.size() > 0) {
|
||||
maxY = minY = buffer1[0];
|
||||
}
|
||||
for (int i=0; i< buffer1.size(); i++) {
|
||||
minY = min(minY, buffer1[i]);
|
||||
maxY = max(maxY, buffer1[i]);
|
||||
}
|
||||
for (int i=0; i< buffer2.size(); i++) {
|
||||
minY = min(minY, buffer2[i]);
|
||||
maxY = max(maxY, buffer2[i]);
|
||||
}
|
||||
for (int i=0; i< buffer3.size(); i++) {
|
||||
minY = min(minY, buffer3[i]);
|
||||
maxY = max(maxY, buffer3[i]);
|
||||
}
|
||||
//Serial.printf("Data range: %f ~ %f\n", minY, maxY);
|
||||
|
||||
float MIN_DELTA = 10.0;
|
||||
if (maxY - minY < MIN_DELTA) {
|
||||
float mid = (maxY + minY) / 2;
|
||||
maxY = mid + MIN_DELTA / 2;
|
||||
minY = mid - MIN_DELTA / 2;
|
||||
} else {
|
||||
float extra = (maxY - minY) / 10;
|
||||
maxY += extra;
|
||||
minY -= extra;
|
||||
}
|
||||
//Serial.printf("Y range: %f ~ %f\n", minY, maxY);
|
||||
|
||||
printTicks(_canvas, 5, minY, maxY);
|
||||
|
||||
int16_t last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer1.size(); i++) {
|
||||
int16_t y = mapf(buffer1[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_1);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
|
||||
last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer2.size(); i++) {
|
||||
int16_t y = mapf(buffer2[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_2);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
|
||||
last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer3.size(); i++) {
|
||||
int16_t y = mapf(buffer3[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_3);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printTicks(GFXcanvas16 *_canvas, uint8_t ticks, float minY, float maxY) {
|
||||
_canvas->setTextSize(1);
|
||||
_canvas->setTextColor(TICKTEXT_COLOR);
|
||||
// Draw ticks
|
||||
for (int t=0; t<ticks; t++) {
|
||||
float v = map(t, 0, ticks-1, minY, maxY);
|
||||
uint16_t y = map(t, 0, ticks-1, ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER - 4, PLOT_TOPBUFFER);
|
||||
printLabel(_canvas, 0, y, v);
|
||||
uint16_t line_y = map(t, 0, ticks-1, ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER, PLOT_TOPBUFFER);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER, line_y, ARCADA_TFT_WIDTH, line_y, TICKLINE_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
void printLabel(GFXcanvas16 *_canvas, uint16_t x, uint16_t y, float val) {
|
||||
char label[20];
|
||||
if (abs(val) < 1) {
|
||||
snprintf(label, 19, "%0.2f", val);
|
||||
} else if (abs(val) < 10) {
|
||||
snprintf(label, 19, "%0.1f", val);
|
||||
} else {
|
||||
snprintf(label, 19, "%d", (int)val);
|
||||
}
|
||||
|
||||
_canvas->setCursor(PLOT_LEFTBUFFER-strlen(label)*6-5, y);
|
||||
_canvas->print(label);
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int16_t minwave, maxwave;
|
||||
short sampleBuffer[256];// buffer to read samples into, each sample is 16-bits
|
||||
volatile int samplesRead;// number of samples read
|
||||
|
||||
int32_t getPDMwave(int32_t samples) {
|
||||
minwave = 30000;
|
||||
maxwave = -30000;
|
||||
|
||||
while (samples > 0) {
|
||||
if (!samplesRead) {
|
||||
yield();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < samplesRead; i++) {
|
||||
minwave = min(sampleBuffer[i], minwave);
|
||||
maxwave = max(sampleBuffer[i], maxwave);
|
||||
//Serial.println(sampleBuffer[i]);
|
||||
samples--;
|
||||
}
|
||||
// clear the read count
|
||||
samplesRead = 0;
|
||||
}
|
||||
return maxwave-minwave;
|
||||
}
|
||||
|
||||
|
||||
void onPDMdata() {
|
||||
// query the number of bytes available
|
||||
int bytesAvailable = PDM.available();
|
||||
|
||||
// read into the sample buffer
|
||||
PDM.read(sampleBuffer, bytesAvailable);
|
||||
|
||||
// 16-bit, 2 bytes per sample
|
||||
samplesRead = bytesAvailable / 2;
|
||||
}
|
||||
|
||||
float mapf(float x, float in_min, float in_max,
|
||||
float out_min, float out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Input a value 0 to 255 to get a color value.
|
||||
// The colours are a transition r - g - b - back to r.
|
||||
uint32_t Wheel(byte WheelPos) {
|
||||
WheelPos = 255 - WheelPos;
|
||||
if(WheelPos < 85) {
|
||||
return pixel.Color(255 - WheelPos * 3, 0, WheelPos * 3);
|
||||
}
|
||||
if(WheelPos < 170) {
|
||||
WheelPos -= 85;
|
||||
return pixel.Color(0, WheelPos * 3, 255 - WheelPos * 3);
|
||||
}
|
||||
WheelPos -= 170;
|
||||
return pixel.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
|
||||
}
|
||||
1095
examples/full_board_tests/adabox015_clue_plotter/coin.h
Normal file
1095
examples/full_board_tests/adabox015_clue_plotter/coin.h
Normal file
File diff suppressed because it is too large
Load diff
5283
examples/full_board_tests/adabox015_clue_plotter/digikey_logo.h
Normal file
5283
examples/full_board_tests/adabox015_clue_plotter/digikey_logo.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,71 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
#include <Adafruit_LSM6DS33.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <CircularBuffer.h>
|
||||
|
||||
extern Adafruit_Arcada arcada;
|
||||
extern Adafruit_LSM6DS33 lsm6ds33;
|
||||
sensors_event_t accel_event;
|
||||
|
||||
#define Y_LEVEL_TOP 10.0
|
||||
#define Y_LEVEL_BOTTOM -10.0
|
||||
#define X_LEVEL_LEFT 10.0
|
||||
#define X_LEVEL_RIGHT -10.0
|
||||
#define BUBBLE_R 20
|
||||
|
||||
float bubble_x = 0, bubble_y = 0;
|
||||
int screen_mid_x, screen_mid_y, largecircle_r;
|
||||
float mapf(float x, float in_min, float in_max, float out_min, float out_max);
|
||||
void start_level() {
|
||||
screen_mid_x = arcada.display->width() / 2;
|
||||
screen_mid_y = arcada.display->height() / 2;
|
||||
largecircle_r = min(screen_mid_x, screen_mid_y) - 1;
|
||||
|
||||
GFXcanvas16 *canvas = arcada.getCanvas();
|
||||
canvas->fillScreen(ARCADA_BLACK);
|
||||
|
||||
bubble_x = screen_mid_x;
|
||||
bubble_y = screen_mid_y;
|
||||
}
|
||||
|
||||
void draw_level() {
|
||||
lsm6ds33.getEvent(&accel_event, NULL, NULL);
|
||||
|
||||
/* Display the results (acceleration is measured in m/s^2)
|
||||
Serial.print("Accel X: ");
|
||||
Serial.print(accel_event.acceleration.x);
|
||||
Serial.print(" \t, \tY: ");
|
||||
Serial.print(accel_event.acceleration.y);
|
||||
Serial.print(" \t, \tZ: ");
|
||||
Serial.print(accel_event.acceleration.z);
|
||||
Serial.println(" m/s^2 ");
|
||||
*/
|
||||
|
||||
GFXcanvas16 *canvas = arcada.getCanvas();
|
||||
// erase old bubble
|
||||
canvas->fillCircle(bubble_x, bubble_y, BUBBLE_R, ARCADA_BLACK);
|
||||
|
||||
// draw rings
|
||||
canvas->drawCircle(screen_mid_x, screen_mid_x, largecircle_r, ARCADA_WHITE);
|
||||
canvas->drawCircle(screen_mid_x, screen_mid_x, largecircle_r / 2,
|
||||
__builtin_bswap16(ARCADA_YELLOW));
|
||||
canvas->drawCircle(screen_mid_x, screen_mid_x, largecircle_r / 4,
|
||||
__builtin_bswap16(ARCADA_GREEN));
|
||||
|
||||
// calculate new bubble location & draw it
|
||||
bubble_x = mapf(accel_event.acceleration.x, X_LEVEL_LEFT, X_LEVEL_RIGHT,
|
||||
screen_mid_x - largecircle_r + BUBBLE_R + 2,
|
||||
screen_mid_x + largecircle_r - BUBBLE_R - 2);
|
||||
bubble_y = mapf(accel_event.acceleration.y, Y_LEVEL_TOP, Y_LEVEL_BOTTOM,
|
||||
screen_mid_x - largecircle_r + BUBBLE_R + 2,
|
||||
screen_mid_x + largecircle_r - BUBBLE_R - 2);
|
||||
|
||||
if ((abs(bubble_x - screen_mid_x) < (largecircle_r / 4 - BUBBLE_R)) &&
|
||||
(abs(bubble_y - screen_mid_y) < (largecircle_r / 4 - BUBBLE_R))) {
|
||||
canvas->fillCircle(bubble_x, bubble_y, BUBBLE_R,
|
||||
__builtin_bswap16(ARCADA_GREEN));
|
||||
} else {
|
||||
canvas->fillCircle(bubble_x, bubble_y, BUBBLE_R,
|
||||
__builtin_bswap16(ARCADA_RED));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,409 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
#include <CircularBuffer.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_LSM6DS33.h>
|
||||
#include <Adafruit_LIS3MDL.h>
|
||||
#include <Adafruit_SHT31.h>
|
||||
#include <Adafruit_APDS9960.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <PDM.h>
|
||||
|
||||
Adafruit_Arcada arcada;
|
||||
Adafruit_LSM6DS33 lsm6ds33;
|
||||
Adafruit_LIS3MDL lis3mdl;
|
||||
Adafruit_SHT31 sht30;
|
||||
Adafruit_APDS9960 apds9960;
|
||||
Adafruit_BMP280 bmp280;
|
||||
extern PDMClass PDM;
|
||||
#define WHITE_LED 43
|
||||
|
||||
// Color definitions
|
||||
#define BACKGROUND_COLOR __builtin_bswap16(ARCADA_BLACK)
|
||||
#define BORDER_COLOR __builtin_bswap16(ARCADA_BLUE)
|
||||
#define PLOT_COLOR_1 __builtin_bswap16(ARCADA_PINK)
|
||||
#define PLOT_COLOR_2 __builtin_bswap16(ARCADA_GREENYELLOW)
|
||||
#define PLOT_COLOR_3 __builtin_bswap16(ARCADA_CYAN)
|
||||
#define TITLE_COLOR __builtin_bswap16(ARCADA_WHITE)
|
||||
#define TICKTEXT_COLOR __builtin_bswap16(ARCADA_WHITE)
|
||||
#define TICKLINE_COLOR __builtin_bswap16(ARCADA_DARKGREY)
|
||||
|
||||
// Buffers surrounding the plot area
|
||||
#define PLOT_TOPBUFFER 20
|
||||
#define PLOT_LEFTBUFFER 40
|
||||
#define PLOT_BOTTOMBUFFER 20
|
||||
#define PLOT_W (ARCADA_TFT_WIDTH - PLOT_LEFTBUFFER)
|
||||
#define PLOT_H (ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER - PLOT_TOPBUFFER)
|
||||
|
||||
// millisecond delay between samples
|
||||
#define DELAY_PER_SAMPLE 50
|
||||
void plotBuffer(GFXcanvas16 *_canvas, const char *title,
|
||||
CircularBuffer<float, PLOT_W> &buffer1,
|
||||
CircularBuffer<float, PLOT_W> &buffer2,
|
||||
CircularBuffer<float, PLOT_W> &buffer3);
|
||||
|
||||
// Buffer for our plot data
|
||||
CircularBuffer<float, PLOT_W> data_buffer;
|
||||
CircularBuffer<float, PLOT_W> data_buffer2;
|
||||
CircularBuffer<float, PLOT_W> data_buffer3;
|
||||
|
||||
int8_t sensornum = 0;
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
Serial.print("Hello! Arcada CLUE sensor plotter");
|
||||
//while (!Serial) yield();
|
||||
|
||||
// Start TFT and fill black
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
while (1) delay(10);
|
||||
}
|
||||
arcada.displayBegin();
|
||||
|
||||
// Turn on backlight
|
||||
arcada.setBacklight(255);
|
||||
|
||||
if (! arcada.createFrameBuffer(ARCADA_TFT_WIDTH, ARCADA_TFT_HEIGHT)) {
|
||||
Serial.print("Failed to allocate framebuffer");
|
||||
while (1);
|
||||
}
|
||||
if (!apds9960.begin() || !lsm6ds33.begin_I2C() || !lis3mdl.begin_I2C() ||
|
||||
!sht30.begin(0x44) || !bmp280.begin()) {
|
||||
Serial.println("Failed to find CLUE sensors!");
|
||||
arcada.haltBox("Failed to init CLUE sensors");
|
||||
}
|
||||
/********** Check MIC */
|
||||
PDM.onReceive(onPDMdata);
|
||||
if (!PDM.begin(1, 16000)) {
|
||||
Serial.println("**Failed to start PDM!");
|
||||
}
|
||||
|
||||
data_buffer.clear();
|
||||
data_buffer2.clear();
|
||||
data_buffer3.clear();
|
||||
pinMode(WHITE_LED, OUTPUT);
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
|
||||
uint32_t timestamp = 0;
|
||||
|
||||
void loop() {
|
||||
timestamp = millis();
|
||||
|
||||
arcada.readButtons();
|
||||
uint8_t justPressed = arcada.justPressedButtons();
|
||||
uint8_t justReleased = arcada.justReleasedButtons();
|
||||
|
||||
(void) justPressed;
|
||||
|
||||
if (justReleased & ARCADA_BUTTONMASK_LEFT) {
|
||||
sensornum--;
|
||||
data_buffer.clear();
|
||||
data_buffer2.clear();
|
||||
data_buffer3.clear();
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
if (justReleased & ARCADA_BUTTONMASK_RIGHT) {
|
||||
sensornum++;
|
||||
data_buffer.clear();
|
||||
data_buffer2.clear();
|
||||
data_buffer3.clear();
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
|
||||
if (sensornum == 0) {
|
||||
float t = bmp280.readTemperature();
|
||||
data_buffer.push(t);
|
||||
Serial.printf("Temp: %f\n", t);
|
||||
plotBuffer(arcada.getCanvas(), "Temperature (C)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 1) {
|
||||
float p = bmp280.readPressure();
|
||||
data_buffer.push(p);
|
||||
Serial.printf("Pressure: %f Pa\n", p);
|
||||
plotBuffer(arcada.getCanvas(), "Pressure (Pa)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 2) {
|
||||
float h = sht30.readHumidity();
|
||||
data_buffer.push(h);
|
||||
Serial.printf("Humid: %f %\n", h);
|
||||
plotBuffer(arcada.getCanvas(),"Humidity (%)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 3) {
|
||||
uint16_t r, g, b, c;
|
||||
apds9960.enableColor(true);
|
||||
//wait for color data to be ready
|
||||
while(! apds9960.colorDataReady()) {
|
||||
delay(5);
|
||||
}
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
data_buffer.push(c);
|
||||
Serial.printf("Light: %d\n", c);
|
||||
plotBuffer(arcada.getCanvas(),"Light",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 4) {
|
||||
uint16_t r, g, b, c;
|
||||
digitalWrite(WHITE_LED, HIGH);
|
||||
apds9960.enableColor(true);
|
||||
//wait for color data to be ready
|
||||
while(! apds9960.colorDataReady()) {
|
||||
delay(5);
|
||||
}
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
data_buffer.push(r);
|
||||
data_buffer2.push(g);
|
||||
data_buffer3.push(b);
|
||||
Serial.printf("Color: %d %d %d\n", r, g, b);
|
||||
plotBuffer(arcada.getCanvas(),"Color (RGB)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 5) {
|
||||
apds9960.enableProximity(true);
|
||||
uint16_t p = apds9960.readProximity();
|
||||
data_buffer.push(p);
|
||||
Serial.printf("Proximity: %d\n", p);
|
||||
plotBuffer(arcada.getCanvas(),"Proximity",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 6) {
|
||||
uint16_t r, g, b, c;
|
||||
apds9960.enableProximity(true);
|
||||
uint16_t p = apds9960.readProximity();
|
||||
if (p < 200) {
|
||||
// turn off LED and leave
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
} else {
|
||||
digitalWrite(WHITE_LED, HIGH);
|
||||
apds9960.enableColor(true);
|
||||
apds9960.setADCIntegrationTime(3);
|
||||
apds9960.setADCGain(APDS9960_AGAIN_64X);
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
data_buffer.push(c);
|
||||
Serial.printf("Pulse: %d\n", c);
|
||||
}
|
||||
plotBuffer(arcada.getCanvas(),"Pulse",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 7) {
|
||||
uint32_t pdm_vol = getPDMwave(256);
|
||||
data_buffer.push(pdm_vol);
|
||||
Serial.print("PDM volume: "); Serial.println(pdm_vol);
|
||||
plotBuffer(arcada.getCanvas(), "Mic Volume",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 8) {
|
||||
sensors_event_t accel;
|
||||
lsm6ds33.getEvent(&accel, NULL, NULL);
|
||||
float x = accel.acceleration.x;
|
||||
float y = accel.acceleration.y;
|
||||
float z = accel.acceleration.z;
|
||||
data_buffer.push(x);
|
||||
data_buffer2.push(y);
|
||||
data_buffer3.push(z);
|
||||
Serial.printf("Accel: %f %f %f\n", x, y, z);
|
||||
plotBuffer(arcada.getCanvas(), "Accel (m/s^2)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 9) {
|
||||
sensors_event_t gyro;
|
||||
lsm6ds33.getEvent(NULL, &gyro, NULL);
|
||||
float x = gyro.gyro.x * SENSORS_RADS_TO_DPS;
|
||||
float y = gyro.gyro.y * SENSORS_RADS_TO_DPS;
|
||||
float z = gyro.gyro.z * SENSORS_RADS_TO_DPS;
|
||||
data_buffer.push(x);
|
||||
data_buffer2.push(y);
|
||||
data_buffer3.push(z);
|
||||
Serial.printf("Gyro: %f %f %f\n", x, y, z);
|
||||
plotBuffer(arcada.getCanvas(), "Gyro (dps)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else if (sensornum == 10) {
|
||||
sensors_event_t mag;
|
||||
lis3mdl.getEvent(&mag);
|
||||
float x = mag.magnetic.x;
|
||||
float y = mag.magnetic.y;
|
||||
float z = mag.magnetic.z;
|
||||
data_buffer.push(x);
|
||||
data_buffer2.push(y);
|
||||
data_buffer3.push(z);
|
||||
Serial.printf("Mag: %f %f %f\n", x, y, z);
|
||||
plotBuffer(arcada.getCanvas(), "Mag (uT)",
|
||||
data_buffer, data_buffer2, data_buffer3);
|
||||
}
|
||||
else {
|
||||
data_buffer.clear();
|
||||
sensornum = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
arcada.blitFrameBuffer(0, 0, false, true);
|
||||
//Serial.printf("Drew in %d ms\n", millis()-timestamp);
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
|
||||
|
||||
void plotBuffer(GFXcanvas16 *_canvas, const char *title,
|
||||
CircularBuffer<float, PLOT_W> &buffer1,
|
||||
CircularBuffer<float, PLOT_W> &buffer2,
|
||||
CircularBuffer<float, PLOT_W> &buffer3) {
|
||||
_canvas->fillScreen(BACKGROUND_COLOR);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER-1, PLOT_TOPBUFFER,
|
||||
PLOT_LEFTBUFFER-1, PLOT_H+PLOT_TOPBUFFER, BORDER_COLOR);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER-1, PLOT_TOPBUFFER+PLOT_H+1,
|
||||
ARCADA_TFT_WIDTH, PLOT_TOPBUFFER+PLOT_H+1, BORDER_COLOR);
|
||||
_canvas->setTextSize(2);
|
||||
_canvas->setTextColor(TITLE_COLOR);
|
||||
uint16_t title_len = strlen(title) * 12;
|
||||
_canvas->setCursor((_canvas->width()-title_len)/2, 0);
|
||||
_canvas->print(title);
|
||||
|
||||
float minY = 0;
|
||||
float maxY = 0;
|
||||
|
||||
if (buffer1.size() > 0) {
|
||||
maxY = minY = buffer1[0];
|
||||
}
|
||||
for (int i=0; i< buffer1.size(); i++) {
|
||||
minY = min(minY, buffer1[i]);
|
||||
maxY = max(maxY, buffer1[i]);
|
||||
}
|
||||
for (int i=0; i< buffer2.size(); i++) {
|
||||
minY = min(minY, buffer2[i]);
|
||||
maxY = max(maxY, buffer2[i]);
|
||||
}
|
||||
for (int i=0; i< buffer3.size(); i++) {
|
||||
minY = min(minY, buffer3[i]);
|
||||
maxY = max(maxY, buffer3[i]);
|
||||
}
|
||||
//Serial.printf("Data range: %f ~ %f\n", minY, maxY);
|
||||
|
||||
float MIN_DELTA = 10.0;
|
||||
if (maxY - minY < MIN_DELTA) {
|
||||
float mid = (maxY + minY) / 2;
|
||||
maxY = mid + MIN_DELTA / 2;
|
||||
minY = mid - MIN_DELTA / 2;
|
||||
} else {
|
||||
float extra = (maxY - minY) / 10;
|
||||
maxY += extra;
|
||||
minY -= extra;
|
||||
}
|
||||
//Serial.printf("Y range: %f ~ %f\n", minY, maxY);
|
||||
|
||||
printTicks(_canvas, 5, minY, maxY);
|
||||
|
||||
int16_t last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer1.size(); i++) {
|
||||
int16_t y = mapf(buffer1[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_1);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
|
||||
last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer2.size(); i++) {
|
||||
int16_t y = mapf(buffer2[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_2);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
|
||||
last_y = 0, last_x = 0;
|
||||
for (int i=0; i<buffer3.size(); i++) {
|
||||
int16_t y = mapf(buffer3[i], minY, maxY, PLOT_TOPBUFFER+PLOT_H, PLOT_TOPBUFFER);
|
||||
int16_t x = PLOT_LEFTBUFFER+i;
|
||||
if (i == 0) {
|
||||
last_y = y;
|
||||
last_x = x;
|
||||
}
|
||||
_canvas->drawLine(last_x, last_y, x, y, PLOT_COLOR_3);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printTicks(GFXcanvas16 *_canvas, uint8_t ticks, float minY, float maxY) {
|
||||
_canvas->setTextSize(1);
|
||||
_canvas->setTextColor(TICKTEXT_COLOR);
|
||||
// Draw ticks
|
||||
for (int t=0; t<ticks; t++) {
|
||||
float v = mapf(t, 0, ticks-1, minY, maxY);
|
||||
uint16_t y = mapf(t, 0, ticks-1, ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER - 4, PLOT_TOPBUFFER);
|
||||
printLabel(_canvas, 0, y, v);
|
||||
uint16_t line_y = mapf(t, 0, ticks-1, ARCADA_TFT_HEIGHT - PLOT_BOTTOMBUFFER, PLOT_TOPBUFFER);
|
||||
_canvas->drawLine(PLOT_LEFTBUFFER, line_y, ARCADA_TFT_WIDTH, line_y, TICKLINE_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
void printLabel(GFXcanvas16 *_canvas, uint16_t x, uint16_t y, float val) {
|
||||
char label[20];
|
||||
if (abs(val) < 1) {
|
||||
snprintf(label, 19, "%0.2f", val);
|
||||
} else if (abs(val) < 10) {
|
||||
snprintf(label, 19, "%0.1f", val);
|
||||
} else {
|
||||
snprintf(label, 19, "%d", (int)val);
|
||||
}
|
||||
|
||||
_canvas->setCursor(PLOT_LEFTBUFFER-strlen(label)*6-5, y);
|
||||
_canvas->print(label);
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int16_t minwave, maxwave;
|
||||
short sampleBuffer[256];// buffer to read samples into, each sample is 16-bits
|
||||
volatile int samplesRead;// number of samples read
|
||||
|
||||
int32_t getPDMwave(int32_t samples) {
|
||||
minwave = 30000;
|
||||
maxwave = -30000;
|
||||
|
||||
while (samples > 0) {
|
||||
if (!samplesRead) {
|
||||
yield();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < samplesRead; i++) {
|
||||
minwave = min(sampleBuffer[i], minwave);
|
||||
maxwave = max(sampleBuffer[i], maxwave);
|
||||
//Serial.println(sampleBuffer[i]);
|
||||
samples--;
|
||||
}
|
||||
// clear the read count
|
||||
samplesRead = 0;
|
||||
}
|
||||
return maxwave-minwave;
|
||||
}
|
||||
|
||||
|
||||
void onPDMdata() {
|
||||
// query the number of bytes available
|
||||
int bytesAvailable = PDM.available();
|
||||
|
||||
// read into the sample buffer
|
||||
PDM.read(sampleBuffer, bytesAvailable);
|
||||
|
||||
// 16-bit, 2 bytes per sample
|
||||
samplesRead = bytesAvailable / 2;
|
||||
}
|
||||
|
||||
static float mapf(float x, float in_min, float in_max,
|
||||
float out_min, float out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
317
examples/full_board_tests/arcada_clue_test/arcada_clue_test.ino
Normal file
317
examples/full_board_tests/arcada_clue_test/arcada_clue_test.ino
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
#include <Adafruit_Arcada.h>
|
||||
#include <Adafruit_SPIFlash.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_LSM6DS33.h>
|
||||
#include <Adafruit_LSM6DS3TRC.h>
|
||||
#include <Adafruit_LIS3MDL.h>
|
||||
#include <Adafruit_SHT31.h>
|
||||
#include <Adafruit_APDS9960.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <PDM.h>
|
||||
|
||||
#define WHITE_LED 43
|
||||
|
||||
Adafruit_Arcada arcada;
|
||||
|
||||
Adafruit_LSM6DS33 lsm6ds33;
|
||||
Adafruit_LSM6DS3TRC lsm6ds3trc;
|
||||
bool use_lsm6ds33 = false, use_lsm6ds3trc = false;
|
||||
|
||||
Adafruit_LIS3MDL lis3mdl;
|
||||
Adafruit_SHT31 sht30;
|
||||
Adafruit_APDS9960 apds9960;
|
||||
Adafruit_BMP280 bmp280;
|
||||
extern PDMClass PDM;
|
||||
extern Adafruit_FlashTransport_QSPI flashTransport;
|
||||
extern Adafruit_SPIFlash Arcada_QSPI_Flash;
|
||||
|
||||
uint32_t buttons, last_buttons;
|
||||
uint8_t j = 0; // neopixel counter for rainbow
|
||||
|
||||
// Check the timer callback, this function is called every millisecond!
|
||||
volatile uint16_t milliseconds = 0;
|
||||
void timercallback() {
|
||||
analogWrite(LED_BUILTIN, milliseconds); // pulse the LED
|
||||
if (milliseconds == 0) {
|
||||
milliseconds = 255;
|
||||
} else {
|
||||
milliseconds--;
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// enable NFC pins
|
||||
if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
|
||||
Serial.println("Fix NFC pins");
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
|
||||
NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
|
||||
Serial.println("Done");
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
pinMode(WHITE_LED, OUTPUT);
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
|
||||
Serial.println("Hello! Arcada Clue test");
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
while (1);
|
||||
}
|
||||
arcada.displayBegin();
|
||||
Serial.println("Arcada display begin");
|
||||
|
||||
for (int i=0; i<250; i+=10) {
|
||||
arcada.setBacklight(i);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
arcada.display->setCursor(0, 0);
|
||||
arcada.display->setTextWrap(true);
|
||||
arcada.display->setTextSize(2);
|
||||
|
||||
/********** Check MIC */
|
||||
PDM.onReceive(onPDMdata);
|
||||
if (!PDM.begin(1, 16000)) {
|
||||
Serial.println("**Failed to start PDM!");
|
||||
}
|
||||
|
||||
/********** Check QSPI manually */
|
||||
if (!Arcada_QSPI_Flash.begin()){
|
||||
Serial.println("Could not find flash on QSPI bus!");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
arcada.display->println("QSPI Flash FAIL");
|
||||
} else {
|
||||
uint32_t jedec;
|
||||
jedec = Arcada_QSPI_Flash.getJEDECID();
|
||||
Serial.print("JEDEC ID: 0x"); Serial.println(jedec, HEX);
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
arcada.display->print("QSPI JEDEC: 0x"); arcada.display->println(jedec, HEX);
|
||||
}
|
||||
|
||||
/********** Check filesystem next */
|
||||
if (!arcada.filesysBegin()) {
|
||||
Serial.println("Failed to load filesys");
|
||||
arcada.display->setTextColor(ARCADA_YELLOW);
|
||||
arcada.display->println("Filesystem not found");
|
||||
} else {
|
||||
Serial.println("Filesys OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
arcada.display->println("Filesystem OK");
|
||||
}
|
||||
|
||||
arcada.display->setTextColor(ARCADA_WHITE);
|
||||
arcada.display->println("Sensors Found: ");
|
||||
|
||||
/********** Check APDS */
|
||||
if (!apds9960.begin()) {
|
||||
Serial.println("No APDS9960 found");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
} else {
|
||||
Serial.println("**APDS9960 OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
apds9960.enableColor(true);
|
||||
}
|
||||
arcada.display->print("APDS9960 ");
|
||||
|
||||
/********** Check LSM6DS3 or LSM6DS3TR-C */
|
||||
if (lsm6ds33.begin_I2C()) {
|
||||
use_lsm6ds33 = true;
|
||||
} else if (lsm6ds3trc.begin_I2C()) {
|
||||
use_lsm6ds3trc = true;
|
||||
}
|
||||
|
||||
if (!use_lsm6ds3trc && !use_lsm6ds33) {
|
||||
Serial.println("No LSM6DS3x found");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
} else {
|
||||
Serial.println("LSM6DS3x OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
}
|
||||
arcada.display->println("LSM6DS3x ");
|
||||
|
||||
/********** Check LIS3MDL */
|
||||
if (!lis3mdl.begin_I2C()) {
|
||||
Serial.println("No LIS3MDL found");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
} else {
|
||||
Serial.println("**LIS3MDL OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
}
|
||||
arcada.display->print("LIS3MDL ");
|
||||
|
||||
/********** Check SHT3x */
|
||||
if (!sht30.begin(0x44)) {
|
||||
Serial.println("No SHT30 found");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
} else {
|
||||
Serial.println("**SHT30 OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
}
|
||||
arcada.display->print("SHT30 ");
|
||||
|
||||
/********** Check BMP280 */
|
||||
if (!bmp280.begin()) {
|
||||
Serial.println("No BMP280 found");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
} else {
|
||||
Serial.println("**BMP280 OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
}
|
||||
arcada.display->println("BMP280");
|
||||
|
||||
buttons = last_buttons = 0;
|
||||
arcada.timerCallback(1000, timercallback);
|
||||
arcada.display->setTextWrap(false);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
arcada.display->setTextColor(ARCADA_WHITE, ARCADA_BLACK);
|
||||
arcada.display->setCursor(0, 100);
|
||||
|
||||
arcada.display->print("Temp: ");
|
||||
arcada.display->print(bmp280.readTemperature());
|
||||
arcada.display->print(" C");
|
||||
arcada.display->println(" ");
|
||||
|
||||
arcada.display->print("Baro: ");
|
||||
arcada.display->print(bmp280.readPressure()/100);
|
||||
arcada.display->print(" hPa");
|
||||
arcada.display->println(" ");
|
||||
|
||||
arcada.display->print("Humid: ");
|
||||
arcada.display->print(sht30.readHumidity());
|
||||
arcada.display->print(" %");
|
||||
arcada.display->println(" ");
|
||||
|
||||
uint16_t r, g, b, c;
|
||||
//wait for color data to be ready
|
||||
while(! apds9960.colorDataReady()) {
|
||||
delay(5);
|
||||
}
|
||||
apds9960.getColorData(&r, &g, &b, &c);
|
||||
arcada.display->print("Light: ");
|
||||
arcada.display->print(c);
|
||||
arcada.display->println(" ");
|
||||
|
||||
sensors_event_t accel, gyro, mag, temp;
|
||||
if (use_lsm6ds33) {
|
||||
lsm6ds33.getEvent(&accel, &gyro, &temp);
|
||||
} else if (use_lsm6ds3trc) {
|
||||
lsm6ds3trc.getEvent(&accel, &gyro, &temp);
|
||||
}
|
||||
lis3mdl.getEvent(&mag);
|
||||
arcada.display->print("Accel:");
|
||||
arcada.display->print(accel.acceleration.x, 1);
|
||||
arcada.display->print(",");
|
||||
arcada.display->print(accel.acceleration.y, 1);
|
||||
arcada.display->print(",");
|
||||
arcada.display->print(accel.acceleration.z, 1);
|
||||
arcada.display->println(" ");
|
||||
|
||||
arcada.display->print("Gyro:");
|
||||
arcada.display->print(gyro.gyro.x, 1);
|
||||
arcada.display->print(",");
|
||||
arcada.display->print(gyro.gyro.y, 1);
|
||||
arcada.display->print(",");
|
||||
arcada.display->print(gyro.gyro.z, 1);
|
||||
arcada.display->println(" ");
|
||||
|
||||
arcada.display->print("Mag:");
|
||||
arcada.display->print(mag.magnetic.x, 1);
|
||||
arcada.display->print(",");
|
||||
arcada.display->print(mag.magnetic.y, 1);
|
||||
arcada.display->print(",");
|
||||
arcada.display->print(mag.magnetic.z, 1);
|
||||
arcada.display->println(" ");
|
||||
|
||||
uint32_t pdm_vol = getPDMwave(256);
|
||||
Serial.print("PDM volume: "); Serial.println(pdm_vol);
|
||||
arcada.display->print("Mic: ");
|
||||
arcada.display->print(pdm_vol);
|
||||
arcada.display->println(" ");
|
||||
|
||||
Serial.printf("Drawing %d NeoPixels\n", arcada.pixels.numPixels());
|
||||
for(int32_t i=0; i< arcada.pixels.numPixels(); i++) {
|
||||
arcada.pixels.setPixelColor(i, Wheel(((i * 256 / arcada.pixels.numPixels()) + j*5) & 255));
|
||||
}
|
||||
arcada.pixels.show();
|
||||
j++;
|
||||
|
||||
uint8_t pressed_buttons = arcada.readButtons();
|
||||
|
||||
if (pressed_buttons & ARCADA_BUTTONMASK_A) {
|
||||
Serial.println("BUTTON A");
|
||||
tone(ARCADA_AUDIO_OUT, 4000, 100);
|
||||
} else {
|
||||
tone(ARCADA_AUDIO_OUT, 0);
|
||||
}
|
||||
if (pressed_buttons & ARCADA_BUTTONMASK_B) {
|
||||
Serial.println("BUTTON B");
|
||||
digitalWrite(WHITE_LED, HIGH);
|
||||
} else {
|
||||
digitalWrite(WHITE_LED, LOW);
|
||||
}
|
||||
last_buttons = buttons;
|
||||
}
|
||||
|
||||
|
||||
// Input a value 0 to 255 to get a color value.
|
||||
// The colours are a transition r - g - b - back to r.
|
||||
uint32_t Wheel(byte WheelPos) {
|
||||
if(WheelPos < 85) {
|
||||
return arcada.pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
|
||||
} else if(WheelPos < 170) {
|
||||
WheelPos -= 85;
|
||||
return arcada.pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
|
||||
} else {
|
||||
WheelPos -= 170;
|
||||
return arcada.pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int16_t minwave, maxwave;
|
||||
short sampleBuffer[256];// buffer to read samples into, each sample is 16-bits
|
||||
volatile int samplesRead;// number of samples read
|
||||
|
||||
int32_t getPDMwave(int32_t samples) {
|
||||
minwave = 30000;
|
||||
maxwave = -30000;
|
||||
|
||||
while (samples > 0) {
|
||||
if (!samplesRead) {
|
||||
yield();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < samplesRead; i++) {
|
||||
minwave = min(sampleBuffer[i], minwave);
|
||||
maxwave = max(sampleBuffer[i], maxwave);
|
||||
//Serial.println(sampleBuffer[i]);
|
||||
samples--;
|
||||
}
|
||||
// clear the read count
|
||||
samplesRead = 0;
|
||||
}
|
||||
return maxwave-minwave;
|
||||
}
|
||||
|
||||
|
||||
void onPDMdata() {
|
||||
// query the number of bytes available
|
||||
int bytesAvailable = PDM.available();
|
||||
|
||||
// read into the sample buffer
|
||||
PDM.read(sampleBuffer, bytesAvailable);
|
||||
|
||||
// 16-bit, 2 bytes per sample
|
||||
samplesRead = bytesAvailable / 2;
|
||||
}
|
||||
|
|
@ -87,8 +87,8 @@ void setup() {
|
|||
Serial.println("Accelerometer OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
arcada.display->println("Accelerometer OK!");
|
||||
arcada.accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel.setClick(1, 80);
|
||||
arcada.accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel->setClick(1, 80);
|
||||
}
|
||||
|
||||
/********** Check WiFi*/
|
||||
|
|
@ -115,7 +115,7 @@ void loop() {
|
|||
|
||||
bool playsound = false;
|
||||
if (arcada.hasAccel()) {
|
||||
uint8_t click = arcada.accel.getClick();
|
||||
uint8_t click = arcada.accel->getClick();
|
||||
if (click & 0x30) {
|
||||
Serial.print("Click detected (0x"); Serial.print(click, HEX); Serial.print("): ");
|
||||
if (click & 0x10) Serial.print(" single click");
|
||||
|
|
@ -124,7 +124,7 @@ void loop() {
|
|||
}
|
||||
} else {
|
||||
// no accel, check both SEL/START pressed at once
|
||||
if (arcada.readButtons() & ARCADA_BUTTONMASK_START & ARCADA_BUTTONMASK_SELECT) {
|
||||
if ((arcada.readButtons() & (ARCADA_BUTTONMASK_START | ARCADA_BUTTONMASK_SELECT)) == (ARCADA_BUTTONMASK_START | ARCADA_BUTTONMASK_SELECT)) {
|
||||
playsound = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ void loop() {
|
|||
|
||||
if (arcada.hasAccel()) {
|
||||
sensors_event_t event;
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
|
||||
/* Display the results (acceleration is measured in m/s^2) */
|
||||
Serial.print("Accel: \t X: "); Serial.print(event.acceleration.x);
|
||||
|
|
@ -255,4 +255,4 @@ void play_tune(const uint8_t *audio, uint32_t audio_length) {
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -84,8 +84,8 @@ void setup() {
|
|||
Serial.println("Accelerometer OK!");
|
||||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
arcada.display->println("Accelerometer OK!");
|
||||
arcada.accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel.setClick(1, 80);
|
||||
arcada.accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel->setClick(1, 80);
|
||||
}
|
||||
|
||||
buttons = last_buttons = 0;
|
||||
|
|
@ -97,7 +97,7 @@ void loop() {
|
|||
delay(25); // add some delay so our screen doesnt flicker
|
||||
|
||||
bool playsound = false;
|
||||
uint8_t click = arcada.accel.getClick();
|
||||
uint8_t click = arcada.accel->getClick();
|
||||
if (click & 0x30) {
|
||||
Serial.print("Click detected (0x"); Serial.print(click, HEX); Serial.print("): ");
|
||||
if (click & 0x10) Serial.print(" single click");
|
||||
|
|
@ -112,7 +112,7 @@ void loop() {
|
|||
}
|
||||
|
||||
sensors_event_t event;
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
|
||||
/* Display the results (acceleration is measured in m/s^2) */
|
||||
Serial.print("Accel: \t X: "); Serial.print(event.acceleration.x);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -10,8 +10,6 @@ void setup(void) {
|
|||
//while (!Serial) delay(10);
|
||||
Serial.print("Hello! Hallowing M0 Arcada Test");
|
||||
|
||||
uint8_t i =0;
|
||||
|
||||
// Start TFT and fill black
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
|
|
@ -55,7 +53,7 @@ void setup(void) {
|
|||
|
||||
/********** Check Accel */
|
||||
|
||||
if (! arcada.accel.begin()) {
|
||||
if (! arcada.accel->begin()) {
|
||||
Serial.println("Couldnt start LIS3DH");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
arcada.display->println("LIS3DH FAIL");
|
||||
|
|
@ -63,8 +61,8 @@ void setup(void) {
|
|||
}
|
||||
arcada.display->println("LIS3DH OK");
|
||||
Serial.println("LIS3DH found!");
|
||||
arcada.accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel.setClick(1, 80);
|
||||
arcada.accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel->setClick(1, 80);
|
||||
|
||||
/********** Start speaker */
|
||||
arcada.enableSpeaker(true);
|
||||
|
|
@ -77,7 +75,7 @@ void setup(void) {
|
|||
uint8_t j = 0;
|
||||
|
||||
void loop() {
|
||||
uint8_t click = arcada.accel.getClick();
|
||||
uint8_t click = arcada.accel->getClick();
|
||||
if (click & 0x30) {
|
||||
Serial.print("Click detected (0x"); Serial.print(click, HEX); Serial.print("): ");
|
||||
if (click & 0x10) Serial.print(" single click");
|
||||
|
|
@ -88,7 +86,7 @@ void loop() {
|
|||
}
|
||||
|
||||
sensors_event_t event;
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
|
||||
// Display the results (acceleration is measured in m/s^2)
|
||||
Serial.print("Accel: \t X: "); Serial.print(event.acceleration.x);
|
||||
|
|
@ -195,4 +193,4 @@ uint32_t Wheel(byte WheelPos) {
|
|||
WheelPos -= 170;
|
||||
return arcada.pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -18,14 +18,14 @@ void setup(void) {
|
|||
Serial.print("Failed to begin");
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
||||
// Start TFT and fill black
|
||||
if (!arcada.arcadaBegin()) {
|
||||
Serial.print("Failed to begin");
|
||||
while (1);
|
||||
}
|
||||
arcada.displayBegin();
|
||||
|
||||
|
||||
// Turn on backlight
|
||||
arcada.setBacklight(255);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ void setup(void) {
|
|||
arcada.display->setTextColor(ARCADA_RED);
|
||||
arcada.display->println("QSPI Flash FAIL");
|
||||
}
|
||||
|
||||
|
||||
uint16_t jedec = Arcada_QSPI_Flash.getJEDECID();
|
||||
Serial.print("JEDEC: "); Serial.println(jedec, HEX);
|
||||
arcada.display->print("QSPI ");
|
||||
|
|
@ -60,23 +60,36 @@ void setup(void) {
|
|||
arcada.display->setTextColor(ARCADA_GREEN);
|
||||
arcada.display->print("JEDEC: 0x"); arcada.display->println(jedec, HEX);
|
||||
|
||||
/********** Check MSA301 */
|
||||
/********** Check MSA301/MSA311 */
|
||||
|
||||
if (! arcada.accel.begin()) {
|
||||
Serial.println("Couldnt start MSA301");
|
||||
bool accel_found = false;
|
||||
|
||||
// MSA301 @ 0x26 on older revs
|
||||
if (arcada.accel->begin()) {
|
||||
arcada.display->println("MSA301 OK");
|
||||
accel_found = true;
|
||||
}
|
||||
// MSA311 @ 0x62 on newer revs
|
||||
if (!accel_found) {
|
||||
if (arcada.accel->begin(0x62)) {
|
||||
arcada.display->println("MSA311 OK");
|
||||
accel_found = true;
|
||||
}
|
||||
}
|
||||
if (!accel_found) {
|
||||
Serial.println("Couldnt start MSA301/311");
|
||||
arcada.display->setTextColor(ARCADA_RED);
|
||||
arcada.display->println("MSA301 FAIL");
|
||||
arcada.display->println("MSA301/311 FAIL");
|
||||
while (1);
|
||||
}
|
||||
arcada.display->println("MSA301 OK");
|
||||
Serial.println("MSA found!");
|
||||
arcada.accel.setPowerMode(MSA301_NORMALMODE);
|
||||
arcada.accel.setDataRate(MSA301_DATARATE_1000_HZ);
|
||||
arcada.accel.setBandwidth(MSA301_BANDWIDTH_500_HZ);
|
||||
arcada.accel.setRange(MSA301_RANGE_2_G);
|
||||
arcada.accel.setResolution(MSA301_RESOLUTION_14 );
|
||||
arcada.accel.setClick(false, false, MSA301_TAPDUR_250_MS, 10);
|
||||
arcada.accel.enableInterrupts(true, true, true, true, true); // enable single/double and xyz activity
|
||||
arcada.accel->setPowerMode(MSA301_NORMALMODE);
|
||||
arcada.accel->setDataRate(MSA301_DATARATE_1000_HZ);
|
||||
arcada.accel->setBandwidth(MSA301_BANDWIDTH_500_HZ);
|
||||
arcada.accel->setRange(MSA301_RANGE_2_G);
|
||||
arcada.accel->setResolution(MSA301_RESOLUTION_14 );
|
||||
arcada.accel->setClick(false, false, MSA301_TAPDUR_250_MS, 10);
|
||||
arcada.accel->enableInterrupts(true, true, true, true, true); // enable single/double and xyz activity
|
||||
|
||||
/********** Start speaker */
|
||||
arcada.enableSpeaker(true);
|
||||
|
|
@ -90,11 +103,11 @@ void setup(void) {
|
|||
uint8_t j = 0;
|
||||
|
||||
void loop() {
|
||||
uint8_t clickstat = arcada.accel.getClick();
|
||||
uint8_t clickstat = arcada.accel->getClick();
|
||||
if (clickstat) {
|
||||
Serial.print("Click = 0x"); Serial.println(clickstat, HEX);
|
||||
}
|
||||
uint8_t motionstat = arcada.accel.getMotionInterruptStatus();
|
||||
uint8_t motionstat = arcada.accel->getMotionInterruptStatus();
|
||||
if (motionstat) {
|
||||
Serial.print("Motion IRQ = 0x"); Serial.println(motionstat, HEX);
|
||||
if (motionstat & (1<<5)) {
|
||||
|
|
@ -109,13 +122,13 @@ void loop() {
|
|||
}
|
||||
|
||||
|
||||
sensors_event_t event;
|
||||
arcada.accel.getEvent(&event);
|
||||
|
||||
// Display the results (acceleration is measured in m/s^2)
|
||||
sensors_event_t event;
|
||||
arcada.accel->getEvent(&event);
|
||||
|
||||
// Display the results (acceleration is measured in m/s^2)
|
||||
Serial.print("Accel: \t X: "); Serial.print(event.acceleration.x);
|
||||
Serial.print(" \tY: "); Serial.print(event.acceleration.y);
|
||||
Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
|
||||
Serial.print(" \tY: "); Serial.print(event.acceleration.y);
|
||||
Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
|
||||
Serial.println(" m/s^2 ");
|
||||
arcada.display->fillRect(0, 40, 240, 20, ARCADA_BLACK);
|
||||
arcada.display->setCursor(0, 40);
|
||||
|
|
@ -152,7 +165,7 @@ void loop() {
|
|||
arcada.display->fillRect(0, 140, 240, 32, ARCADA_BLACK);
|
||||
arcada.display->setCursor(0, 140);
|
||||
arcada.display->setTextColor(ARCADA_WHITE);
|
||||
Serial.print("I2C: ");
|
||||
Serial.print("I2C: ");
|
||||
arcada.display->print("I2C: ");
|
||||
Wire.begin();
|
||||
for (int a=0x10; a<=0x7F; a++) {
|
||||
|
|
@ -163,7 +176,7 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
Serial.printf("Drawing %d NeoPixels", arcada.pixels.numPixels());
|
||||
Serial.printf("Drawing %d NeoPixels", arcada.pixels.numPixels());
|
||||
for(int32_t i=0; i< arcada.pixels.numPixels(); i++) {
|
||||
arcada.pixels.setPixelColor(i, Wheel(((i * 256 / arcada.pixels.numPixels()) + j*5) & 255));
|
||||
}
|
||||
|
|
@ -197,7 +210,7 @@ void loop() {
|
|||
void play_tune(const uint8_t *audio, uint32_t audio_length) {
|
||||
uint32_t t;
|
||||
uint32_t prior, usec = 1000000L / SAMPLE_RATE;
|
||||
|
||||
|
||||
for (uint32_t i=0; i<audio_length; i++) {
|
||||
while((t = micros()) - prior < usec);
|
||||
analogWrite(A0, (uint16_t)audio[i] / 8);
|
||||
|
|
@ -218,4 +231,4 @@ uint32_t Wheel(byte WheelPos) {
|
|||
WheelPos -= 170;
|
||||
return arcada.pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -67,8 +67,8 @@ void setup(void) {
|
|||
while (1);
|
||||
}
|
||||
Serial.println("LIS3DH found!");
|
||||
arcada.accel.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel.setClick(1, 80);
|
||||
arcada.accel->setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!
|
||||
arcada.accel->setClick(1, 80);
|
||||
|
||||
/********** Start speaker */
|
||||
arcada.enableSpeaker(false);
|
||||
|
|
@ -82,7 +82,7 @@ uint8_t j = 0;
|
|||
void loop() {
|
||||
delay(10);
|
||||
|
||||
uint8_t click = arcada.accel.getClick();
|
||||
uint8_t click = arcada.accel->getClick();
|
||||
if (click & 0x30) {
|
||||
Serial.print("Click detected (0x"); Serial.print(click, HEX); Serial.print("): ");
|
||||
if (click & 0x10) Serial.print(" single click");
|
||||
|
|
@ -93,7 +93,7 @@ void loop() {
|
|||
}
|
||||
|
||||
sensors_event_t event;
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
|
||||
// Display the results (acceleration is measured in m/s^2)
|
||||
Serial.print("Accel: \t X: "); Serial.print(event.acceleration.x);
|
||||
|
|
|
|||
|
|
@ -21,18 +21,13 @@
|
|||
|
||||
#include "ESP32BootROM.h"
|
||||
|
||||
//#define DEBUG 1
|
||||
// #define DEBUG 1
|
||||
|
||||
ESP32BootROMClass::ESP32BootROMClass(HardwareSerial& serial, int gpio0Pin, int resetnPin) :
|
||||
_serial(&serial),
|
||||
_gpio0Pin(gpio0Pin),
|
||||
_resetnPin(resetnPin)
|
||||
{
|
||||
ESP32BootROMClass::ESP32BootROMClass(HardwareSerial &serial, int gpio0Pin,
|
||||
int resetnPin)
|
||||
: _serial(&serial), _gpio0Pin(gpio0Pin), _resetnPin(resetnPin) {}
|
||||
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::begin(unsigned long baudrate)
|
||||
{
|
||||
int ESP32BootROMClass::begin(unsigned long baudrate) {
|
||||
_serial->begin(115200);
|
||||
|
||||
pinMode(_gpio0Pin, OUTPUT);
|
||||
|
|
@ -77,16 +72,13 @@ int ESP32BootROMClass::begin(unsigned long baudrate)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void ESP32BootROMClass::end() {
|
||||
_serial->end();
|
||||
}
|
||||
void ESP32BootROMClass::end() { _serial->end(); }
|
||||
|
||||
int ESP32BootROMClass::sync()
|
||||
{
|
||||
const uint8_t data[] = {
|
||||
0x07, 0x07, 0x12, 0x20,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55
|
||||
};
|
||||
int ESP32BootROMClass::sync() {
|
||||
const uint8_t data[] = {0x07, 0x07, 0x12, 0x20, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
|
||||
|
||||
command(0x08, data, sizeof(data));
|
||||
|
||||
|
|
@ -99,36 +91,25 @@ int ESP32BootROMClass::sync()
|
|||
return (results[0] == 0);
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::changeBaudrate(unsigned long baudrate)
|
||||
{
|
||||
const uint32_t data[2] = {
|
||||
baudrate,
|
||||
0
|
||||
};
|
||||
int ESP32BootROMClass::changeBaudrate(unsigned long baudrate) {
|
||||
const uint32_t data[2] = {baudrate, 0};
|
||||
|
||||
command(0x0f, data, sizeof(data));
|
||||
|
||||
return (response(0x0f, 3000) == 0);
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::spiAttach()
|
||||
{
|
||||
const uint8_t data[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int ESP32BootROMClass::spiAttach() {
|
||||
const uint8_t data[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
command(0x0d, data, sizeof(data));
|
||||
|
||||
return (response(0x0d, 3000) == 0);
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::beginFlash(uint32_t offset, uint32_t size, uint32_t chunkSize) {
|
||||
const uint32_t data[4] = {
|
||||
size,
|
||||
size / chunkSize,
|
||||
chunkSize,
|
||||
offset
|
||||
};
|
||||
int ESP32BootROMClass::beginFlash(uint32_t offset, uint32_t size,
|
||||
uint32_t chunkSize) {
|
||||
const uint32_t data[4] = {size, size / chunkSize, chunkSize, offset};
|
||||
|
||||
command(0x02, data, sizeof(data));
|
||||
|
||||
|
|
@ -138,8 +119,7 @@ int ESP32BootROMClass::beginFlash(uint32_t offset, uint32_t size, uint32_t chunk
|
|||
return (response(0x02, 120000) == 0);
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::dataFlash(const void* data, uint32_t length)
|
||||
{
|
||||
int ESP32BootROMClass::dataFlash(const void *data, uint32_t length) {
|
||||
uint32_t cmdData[4 + (_chunkSize / 4)];
|
||||
|
||||
cmdData[0] = length;
|
||||
|
|
@ -159,23 +139,16 @@ int ESP32BootROMClass::dataFlash(const void* data, uint32_t length)
|
|||
}
|
||||
|
||||
int ESP32BootROMClass::endFlash(uint32_t reboot) {
|
||||
const uint32_t data[1] = {
|
||||
reboot
|
||||
};
|
||||
const uint32_t data[1] = {reboot};
|
||||
|
||||
command(0x04, data, sizeof(data));
|
||||
|
||||
return (response(0x04, 3000) == 0);
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::md5Flash(uint32_t offset, uint32_t size, uint8_t* result)
|
||||
{
|
||||
const uint32_t data[4] = {
|
||||
offset,
|
||||
size,
|
||||
0,
|
||||
0
|
||||
};
|
||||
int ESP32BootROMClass::md5Flash(uint32_t offset, uint32_t size,
|
||||
uint8_t *result) {
|
||||
const uint32_t data[4] = {offset, size, 0, 0};
|
||||
|
||||
command(0x13, data, sizeof(data));
|
||||
|
||||
|
|
@ -185,7 +158,7 @@ int ESP32BootROMClass::md5Flash(uint32_t offset, uint32_t size, uint8_t* result)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char temp[3] = { 0, 0, 0 };
|
||||
char temp[3] = {0, 0, 0};
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
temp[0] = asciiResult[i * 2];
|
||||
|
|
@ -197,24 +170,23 @@ int ESP32BootROMClass::md5Flash(uint32_t offset, uint32_t size, uint8_t* result)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void ESP32BootROMClass::command(int opcode, const void* data, uint16_t length)
|
||||
{
|
||||
void ESP32BootROMClass::command(int opcode, const void *data, uint16_t length) {
|
||||
uint32_t checksum = 0;
|
||||
|
||||
if (opcode == 0x03) {
|
||||
checksum = 0xef; // seed
|
||||
|
||||
for (uint16_t i = 16; i < length; i++) {
|
||||
checksum ^= ((const uint8_t*)data)[i];
|
||||
checksum ^= ((const uint8_t *)data)[i];
|
||||
}
|
||||
}
|
||||
|
||||
_serial->write(0xc0);
|
||||
_serial->write((uint8_t)0x00); // direction
|
||||
_serial->write(opcode);
|
||||
_serial->write((uint8_t*)&length, sizeof(length));
|
||||
writeEscapedBytes((uint8_t*)&checksum, sizeof(checksum));
|
||||
writeEscapedBytes((uint8_t*)data, length);
|
||||
_serial->write((uint8_t *)&length, sizeof(length));
|
||||
writeEscapedBytes((uint8_t *)&checksum, sizeof(checksum));
|
||||
writeEscapedBytes((uint8_t *)data, length);
|
||||
_serial->write(0xc0);
|
||||
#ifdef ARDUINO_SAMD_MKRVIDOR4000
|
||||
// _serial->flush(); // doesn't work!
|
||||
|
|
@ -223,14 +195,15 @@ void ESP32BootROMClass::command(int opcode, const void* data, uint16_t length)
|
|||
#endif
|
||||
}
|
||||
|
||||
int ESP32BootROMClass::response(int opcode, unsigned long timeout, void* body)
|
||||
{
|
||||
int ESP32BootROMClass::response(int opcode, unsigned long timeout, void *body) {
|
||||
uint8_t data[10 + 256];
|
||||
uint16_t index = 0;
|
||||
|
||||
uint8_t responseLength = 4;
|
||||
|
||||
for (unsigned long start = millis(); (index < (uint16_t)(10 + responseLength)) && (millis() - start) < timeout;) {
|
||||
for (unsigned long start = millis();
|
||||
(index < (uint16_t)(10 + responseLength)) &&
|
||||
(millis() - start) < timeout;) {
|
||||
if (_serial->available()) {
|
||||
data[index] = _serial->read();
|
||||
|
||||
|
|
@ -262,7 +235,9 @@ int ESP32BootROMClass::response(int opcode, unsigned long timeout, void* body)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (data[0] != 0xc0 || data[1] != 0x01 || data[2] != opcode || data[responseLength + 5] != 0x00 || data[responseLength + 6] != 0x00 || data[responseLength + 9] != 0xc0) {
|
||||
if (data[0] != 0xc0 || data[1] != 0x01 || data[2] != opcode ||
|
||||
data[responseLength + 5] != 0x00 || data[responseLength + 6] != 0x00 ||
|
||||
data[responseLength + 9] != 0xc0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -273,8 +248,8 @@ int ESP32BootROMClass::response(int opcode, unsigned long timeout, void* body)
|
|||
return data[responseLength + 5];
|
||||
}
|
||||
|
||||
void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length)
|
||||
{
|
||||
void ESP32BootROMClass::writeEscapedBytes(const uint8_t *data,
|
||||
uint16_t length) {
|
||||
uint16_t written = 0;
|
||||
|
||||
while (written < length) {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
ESP32BootROM - part of the Firmware Updater for the
|
||||
ESP32BootROM - part of the Firmware Updater for the
|
||||
Arduino MKR WiFi 1010, Arduino MKR Vidor 4000, and Arduino UNO WiFi Rev.2.
|
||||
|
||||
|
||||
Copyright (c) 2018 Arduino SA. All rights reserved.
|
||||
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
|
@ -22,35 +22,35 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
class ESP32BootROMClass {
|
||||
public:
|
||||
ESP32BootROMClass(HardwareSerial& hwSerial, int gpio0Pin, int resetnPin);
|
||||
public:
|
||||
ESP32BootROMClass(HardwareSerial &hwSerial, int gpio0Pin, int resetnPin);
|
||||
|
||||
int begin(unsigned long baudrate);
|
||||
void end();
|
||||
int begin(unsigned long baudrate);
|
||||
void end();
|
||||
|
||||
int beginFlash(uint32_t offset, uint32_t size, uint32_t chunkSize);
|
||||
int dataFlash(const void* data, uint32_t length);
|
||||
int endFlash(uint32_t reboot);
|
||||
int beginFlash(uint32_t offset, uint32_t size, uint32_t chunkSize);
|
||||
int dataFlash(const void *data, uint32_t length);
|
||||
int endFlash(uint32_t reboot);
|
||||
|
||||
int md5Flash(uint32_t offset, uint32_t size, uint8_t* result);
|
||||
int md5Flash(uint32_t offset, uint32_t size, uint8_t *result);
|
||||
|
||||
private:
|
||||
int sync();
|
||||
int changeBaudrate(unsigned long baudrate);
|
||||
int spiAttach();
|
||||
private:
|
||||
int sync();
|
||||
int changeBaudrate(unsigned long baudrate);
|
||||
int spiAttach();
|
||||
|
||||
void command(int opcode, const void* data, uint16_t length);
|
||||
int response(int opcode, unsigned long timeout, void* body = NULL);
|
||||
void command(int opcode, const void *data, uint16_t length);
|
||||
int response(int opcode, unsigned long timeout, void *body = NULL);
|
||||
|
||||
void writeEscapedBytes(const uint8_t* data, uint16_t length);
|
||||
void writeEscapedBytes(const uint8_t *data, uint16_t length);
|
||||
|
||||
private:
|
||||
HardwareSerial* _serial;
|
||||
int _gpio0Pin;
|
||||
int _resetnPin;
|
||||
private:
|
||||
HardwareSerial *_serial;
|
||||
int _gpio0Pin;
|
||||
int _resetnPin;
|
||||
|
||||
uint32_t _flashSequenceNumber;
|
||||
uint32_t _chunkSize;
|
||||
uint32_t _flashSequenceNumber;
|
||||
uint32_t _chunkSize;
|
||||
};
|
||||
|
||||
extern ESP32BootROMClass ESP32BootROM;
|
||||
|
|
|
|||
|
|
@ -32,9 +32,12 @@ uint32_t fromNetwork32(uint32_t from) {
|
|||
} else {
|
||||
uint8_t *pFrom = reinterpret_cast<uint8_t *>(&from);
|
||||
uint32_t to;
|
||||
to = pFrom[0]; to <<= 8;
|
||||
to |= pFrom[1]; to <<= 8;
|
||||
to |= pFrom[2]; to <<= 8;
|
||||
to = pFrom[0];
|
||||
to <<= 8;
|
||||
to |= pFrom[1];
|
||||
to <<= 8;
|
||||
to |= pFrom[2];
|
||||
to <<= 8;
|
||||
to |= pFrom[3];
|
||||
return to;
|
||||
}
|
||||
|
|
@ -47,16 +50,13 @@ uint16_t fromNetwork16(uint16_t from) {
|
|||
} else {
|
||||
uint8_t *pFrom = reinterpret_cast<uint8_t *>(&from);
|
||||
uint16_t to;
|
||||
to = pFrom[0]; to <<= 8;
|
||||
to = pFrom[0];
|
||||
to <<= 8;
|
||||
to |= pFrom[1];
|
||||
return to;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t toNetwork32(uint32_t to) {
|
||||
return fromNetwork32(to);
|
||||
}
|
||||
uint32_t toNetwork32(uint32_t to) { return fromNetwork32(to); }
|
||||
|
||||
uint16_t toNetwork16(uint16_t to) {
|
||||
return fromNetwork16(to);
|
||||
}
|
||||
uint16_t toNetwork16(uint16_t to) { return fromNetwork16(to); }
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,7 +9,7 @@ Adafruit_Arcada arcada;
|
|||
extern Adafruit_SPIFlash Arcada_QSPI_Flash;
|
||||
Adafruit_ADT7410 tempsensor = Adafruit_ADT7410();
|
||||
|
||||
char *esp32_firmware = "/NINAW102.bin";
|
||||
const char *esp32_firmware = "/NINAW102.bin";
|
||||
uint8_t esp32_md5[] = {0x5E, 0x04, 0xC0, 0x5C, 0xD7, 0x71, 0xe6, 0x7F, 0x76, 0xA3, 0xD9, 0xe2, 0x71, 0x5a, 0x59, 0xCE };
|
||||
|
||||
Adafruit_GFX_Button coin = Adafruit_GFX_Button();
|
||||
|
|
@ -114,7 +114,7 @@ void setup() {
|
|||
arcada.display->println("OK!");
|
||||
}
|
||||
|
||||
coin.initButton(arcada.display, 160, 200, 100, 50, ARCADA_WHITE, ARCADA_YELLOW, ARCADA_BLACK, "Sound", 2);
|
||||
coin.initButton(arcada.display, 160, 200, 100, 50, ARCADA_WHITE, ARCADA_YELLOW, ARCADA_BLACK, (char*) "Sound", 2);
|
||||
coin.drawButton();
|
||||
|
||||
analogWriteResolution(12);
|
||||
|
|
@ -191,7 +191,8 @@ void loop() {
|
|||
|
||||
void play_tune(const uint8_t *audio, uint32_t audio_length) {
|
||||
uint32_t t;
|
||||
uint32_t prior, usec = 1000000L / SAMPLE_RATE;
|
||||
uint32_t prior = 0;
|
||||
uint32_t usec = 1000000L / SAMPLE_RATE;
|
||||
analogWriteResolution(8);
|
||||
for (uint32_t i=0; i<audio_length; i++) {
|
||||
while((t = micros()) - prior < usec);
|
||||
|
|
@ -206,7 +207,7 @@ static const int MAX_PAYLOAD_SIZE = 1024;
|
|||
uint32_t firmsize;
|
||||
static uint8_t payload[MAX_PAYLOAD_SIZE];
|
||||
|
||||
boolean write_esp32(char *filename, uint8_t *md5) {
|
||||
boolean write_esp32(const char *filename, uint8_t *md5) {
|
||||
File myFile = arcada.open(filename, FILE_READ);
|
||||
if (!myFile) {
|
||||
Serial.println("Failed to open firmware file");
|
||||
|
|
@ -283,4 +284,4 @@ bool check_md5(uint32_t firmsize, uint8_t *md5_check) {
|
|||
}
|
||||
Serial.println();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ void testlines(uint16_t color) {
|
|||
}
|
||||
}
|
||||
|
||||
void testdrawtext(char *text, uint16_t color) {
|
||||
void testdrawtext(const char *text, uint16_t color) {
|
||||
arcada.display->setCursor(0, 0);
|
||||
arcada.display->setTextColor(color);
|
||||
arcada.display->setTextWrap(true);
|
||||
|
|
@ -255,4 +255,4 @@ void mediabuttons() {
|
|||
arcada.display->fillRoundRect(69, 98, 20, 45, 5, ARCADA_RED);
|
||||
// play color
|
||||
arcada.display->fillTriangle(42, 20, 42, 60, 90, 40, ARCADA_GREEN);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup(void) {
|
|||
|
||||
|
||||
void loop() {
|
||||
char *imagefile = 0;
|
||||
const char *imagefile = 0;
|
||||
arcada.readButtons();
|
||||
uint8_t buttons = arcada.justPressedButtons();
|
||||
Serial.print("Pressed: ");
|
||||
|
|
@ -57,7 +57,7 @@ void loop() {
|
|||
|
||||
// Load full-screen BMP file at position (0,0) (top left).
|
||||
Serial.printf("Loading %s to screen...", imagefile);
|
||||
ImageReturnCode stat = arcada.drawBMP(imagefile, 0, 0);
|
||||
ImageReturnCode stat = arcada.drawBMP((char*) imagefile, 0, 0);
|
||||
if(stat == IMAGE_ERR_FILE_NOT_FOUND) {
|
||||
arcada.haltBox("File not found");
|
||||
} else if(stat == IMAGE_ERR_FORMAT) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ void loop()
|
|||
uint8_t justPressed = arcada.justPressedButtons();
|
||||
uint8_t justReleased = arcada.justReleasedButtons();
|
||||
|
||||
// suppress unused warnings
|
||||
(void) justPressed;
|
||||
(void) justReleased;
|
||||
|
||||
uint8_t buttons = arcada.readButtons();
|
||||
|
||||
Serial.print("Pressed: ");
|
||||
|
|
@ -37,4 +41,4 @@ void loop()
|
|||
if (buttons & ARCADA_BUTTONMASK_SELECT) Serial.print("Sel ");
|
||||
Serial.println();
|
||||
delay(25);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,159 +9,159 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define LOGO_WIDTH 40
|
||||
#define LOGO_WIDTH 40
|
||||
#define LOGO_HEIGHT 40
|
||||
|
||||
const uint8_t logo_gray[LOGO_HEIGHT][LOGO_WIDTH] = {
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X16, 0XD2, 0XEB, 0X39,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01,
|
||||
0XB7, 0XFF, 0XFF, 0XB1, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X71, 0XFF, 0XFF, 0XFF, 0XF7, 0X0D, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X30, 0XF8, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0X57, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XD6, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XA9, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X98, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF2, 0X08, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X51, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X4D, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0D, 0XE8, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X9F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X72,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XEC, 0X02, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0XCB, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0X25, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X22, 0X70, 0X78, 0X77, 0X76, 0X75, 0X74, 0X73,
|
||||
0X72, 0X6C, 0X4D, 0X15, 0X00, 0X00, 0X04, 0XFB, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XDA, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFC, 0XB3, 0X2D, 0X0C, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X3C, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0XDD, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XF8, 0X52, 0XEB, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFE, 0X17, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X46, 0XFD, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF6, 0XC9, 0XFF, 0XFF, 0XFF, 0XC8,
|
||||
0X9F, 0XFF, 0XFF, 0XFF, 0XFF, 0XC4, 0X00, 0X17, 0X3D, 0X41, 0X27, 0X03,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X89, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFA,
|
||||
0XFF, 0XFF, 0XFD, 0X22, 0X0F, 0XFF, 0XFF, 0XFF, 0XFC, 0X76, 0XC4, 0XFE,
|
||||
0XFF, 0XFF, 0XFF, 0XEE, 0XA2, 0X50, 0X0A, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X05, 0XC7, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XC9, 0X00, 0X00, 0XFA, 0XFF, 0XFF,
|
||||
0XE6, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF4, 0XAD,
|
||||
0X5C, 0X10, 0X00, 0X00, 0X00, 0X00, 0X21, 0XEF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XA0, 0X00,
|
||||
0X16, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF9, 0XB7, 0X3D, 0X00, 0X00, 0X00, 0X55,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X68, 0X2B, 0X6A, 0XD9,
|
||||
0XFF, 0XFF, 0X9F, 0X00, 0X58, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XEC,
|
||||
0X00, 0X00, 0X00, 0X00, 0X98, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0X94, 0X00, 0X00, 0X06, 0X91, 0XFF, 0XDC, 0X19, 0XD2, 0XFF, 0XFF, 0XFF,
|
||||
0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XCF, 0X00, 0X00, 0X00, 0X00, 0X09, 0XC6, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XA9, 0X1D, 0X00, 0X00, 0XC6, 0XFF, 0XFF,
|
||||
0XFF, 0XD5, 0X5C, 0X18, 0X00, 0X10, 0X9D, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XB4, 0X14, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X0F, 0XB9, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFB, 0XBC,
|
||||
0X9E, 0XF0, 0XFF, 0XFF, 0XFF, 0X1D, 0X00, 0X00, 0X00, 0X21, 0XC7, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF7, 0X6D, 0X01, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X65, 0XD7, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XDC, 0X9E, 0X9E,
|
||||
0XC7, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XD4,
|
||||
0X2E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X39, 0XAF, 0XEF, 0XFF, 0XFF, 0XFF, 0XE5, 0X64, 0X6C, 0XFF, 0XF2,
|
||||
0XC7, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0X97, 0X09, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X69, 0XF8, 0XFF, 0XFF, 0XFF, 0XFF, 0XD3, 0X18,
|
||||
0X00, 0X5E, 0XFF, 0XA2, 0X00, 0X8E, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XE7, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X64, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XF3, 0X20, 0X00, 0X13, 0XE1, 0XFF, 0XC0, 0X00, 0X05, 0XD5, 0XFF,
|
||||
0XFF, 0XFB, 0XC9, 0XEA, 0XFF, 0XFB, 0XCB, 0X72, 0X0D, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X21, 0XF5,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X97, 0X00, 0X1A, 0XCC, 0XFF, 0XFF, 0XFC,
|
||||
0X20, 0X00, 0X65, 0XFF, 0XFF, 0XFF, 0XF7, 0X55, 0X0C, 0X04, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X9C, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCE, 0X8F, 0XEF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XAD, 0X00, 0X25, 0XFF, 0XFF, 0XFF, 0XFF, 0XF9,
|
||||
0X31, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XF4, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X96, 0X60, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XB9, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X52, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF0, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0X1A, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0XA6, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XB1, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X54, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X08, 0XF2, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFB, 0X3A, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X74, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X4F, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X76, 0X00, 0XD1, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7A, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0XA3, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF9, 0X71,
|
||||
0X00, 0X00, 0X5F, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X7B, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X07, 0XF0, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XF9, 0XA8, 0X2A, 0X00, 0X00, 0X00, 0X01, 0XB5, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7D, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X42, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XF8, 0XB3, 0X5F, 0X10, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0D,
|
||||
0XC3, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7E, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X31,
|
||||
0XFC, 0XFF, 0XF8, 0XB1, 0X5D, 0X0F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X08, 0X94, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X37, 0X4F, 0X0E, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X50, 0XED,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X81, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X1E, 0XC3, 0XFF, 0XFF, 0XFF, 0XFF, 0X82, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X04, 0X83, 0XFC, 0XFF,
|
||||
0XFF, 0X7C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X40, 0XD9, 0XDF, 0X29, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00 };
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X16, 0XD2, 0XEB, 0X39,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01,
|
||||
0XB7, 0XFF, 0XFF, 0XB1, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X71, 0XFF, 0XFF, 0XFF, 0XF7, 0X0D, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X30, 0XF8, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0X57, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XD6, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XA9, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X98, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF2, 0X08, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X51, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X4D, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0D, 0XE8, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X9F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X72,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XEC, 0X02, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0XCB, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0X25, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X22, 0X70, 0X78, 0X77, 0X76, 0X75, 0X74, 0X73,
|
||||
0X72, 0X6C, 0X4D, 0X15, 0X00, 0X00, 0X04, 0XFB, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XDA, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFC, 0XB3, 0X2D, 0X0C, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X3C, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0XDD, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XF8, 0X52, 0XEB, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFE, 0X17, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X46, 0XFD, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF6, 0XC9, 0XFF, 0XFF, 0XFF, 0XC8,
|
||||
0X9F, 0XFF, 0XFF, 0XFF, 0XFF, 0XC4, 0X00, 0X17, 0X3D, 0X41, 0X27, 0X03,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X89, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFA,
|
||||
0XFF, 0XFF, 0XFD, 0X22, 0X0F, 0XFF, 0XFF, 0XFF, 0XFC, 0X76, 0XC4, 0XFE,
|
||||
0XFF, 0XFF, 0XFF, 0XEE, 0XA2, 0X50, 0X0A, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X05, 0XC7, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XC9, 0X00, 0X00, 0XFA, 0XFF, 0XFF,
|
||||
0XE6, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF4, 0XAD,
|
||||
0X5C, 0X10, 0X00, 0X00, 0X00, 0X00, 0X21, 0XEF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XA0, 0X00,
|
||||
0X16, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF9, 0XB7, 0X3D, 0X00, 0X00, 0X00, 0X55,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X68, 0X2B, 0X6A, 0XD9,
|
||||
0XFF, 0XFF, 0X9F, 0X00, 0X58, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XEC,
|
||||
0X00, 0X00, 0X00, 0X00, 0X98, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0X94, 0X00, 0X00, 0X06, 0X91, 0XFF, 0XDC, 0X19, 0XD2, 0XFF, 0XFF, 0XFF,
|
||||
0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XCF, 0X00, 0X00, 0X00, 0X00, 0X09, 0XC6, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XA9, 0X1D, 0X00, 0X00, 0XC6, 0XFF, 0XFF,
|
||||
0XFF, 0XD5, 0X5C, 0X18, 0X00, 0X10, 0X9D, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XB4, 0X14, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X0F, 0XB9, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFB, 0XBC,
|
||||
0X9E, 0XF0, 0XFF, 0XFF, 0XFF, 0X1D, 0X00, 0X00, 0X00, 0X21, 0XC7, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF7, 0X6D, 0X01, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X65, 0XD7, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XDC, 0X9E, 0X9E,
|
||||
0XC7, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XD4,
|
||||
0X2E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X39, 0XAF, 0XEF, 0XFF, 0XFF, 0XFF, 0XE5, 0X64, 0X6C, 0XFF, 0XF2,
|
||||
0XC7, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0X97, 0X09, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X69, 0XF8, 0XFF, 0XFF, 0XFF, 0XFF, 0XD3, 0X18,
|
||||
0X00, 0X5E, 0XFF, 0XA2, 0X00, 0X8E, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XE7, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X64, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XF3, 0X20, 0X00, 0X13, 0XE1, 0XFF, 0XC0, 0X00, 0X05, 0XD5, 0XFF,
|
||||
0XFF, 0XFB, 0XC9, 0XEA, 0XFF, 0XFB, 0XCB, 0X72, 0X0D, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X21, 0XF5,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X97, 0X00, 0X1A, 0XCC, 0XFF, 0XFF, 0XFC,
|
||||
0X20, 0X00, 0X65, 0XFF, 0XFF, 0XFF, 0XF7, 0X55, 0X0C, 0X04, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X9C, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCE, 0X8F, 0XEF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XAD, 0X00, 0X25, 0XFF, 0XFF, 0XFF, 0XFF, 0XF9,
|
||||
0X31, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XF4, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X96, 0X60, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XB9, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X52, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF0, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0X1A, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0XA6, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XB1, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X54, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X08, 0XF2, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFB, 0X3A, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X74, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X4F, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X76, 0X00, 0XD1, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7A, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0XA3, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF9, 0X71,
|
||||
0X00, 0X00, 0X5F, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X7B, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X07, 0XF0, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XF9, 0XA8, 0X2A, 0X00, 0X00, 0X00, 0X01, 0XB5, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7D, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X42, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0XF8, 0XB3, 0X5F, 0X10, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0D,
|
||||
0XC3, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7E, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X31,
|
||||
0XFC, 0XFF, 0XF8, 0XB1, 0X5D, 0X0F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X08, 0X94, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
|
||||
0XFF, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X37, 0X4F, 0X0E, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X50, 0XED,
|
||||
0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X81, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X1E, 0XC3, 0XFF, 0XFF, 0XFF, 0XFF, 0X82, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X04, 0X83, 0XFC, 0XFF,
|
||||
0XFF, 0X7C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X40, 0XD9, 0XDF, 0X29, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
|
||||
0X00, 0X00, 0X00, 0X00};
|
||||
const uint8_t logo_mask[LOGO_HEIGHT][(LOGO_WIDTH + 7) / 8] = {
|
||||
0X00, 0X00, 0X06, 0X00, 0X00, 0X00, 0X00, 0X0F, 0X00, 0X00, 0X00, 0X00,
|
||||
0X0F, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X3F, 0X80,
|
||||
0X00, 0X00, 0X00, 0X7F, 0X80, 0X00, 0X00, 0X00, 0X7F, 0X80, 0X00, 0X00,
|
||||
0X00, 0XFF, 0XC0, 0X00, 0X00, 0X00, 0XFF, 0XC0, 0X00, 0X00, 0X01, 0XFF,
|
||||
0XC0, 0X00, 0X00, 0X01, 0XFF, 0XC0, 0X00, 0XFF, 0XF9, 0XFF, 0XC0, 0X00,
|
||||
0XFF, 0XFD, 0XFF, 0XC0, 0X00, 0X7F, 0XFF, 0XFF, 0XC0, 0X00, 0X7F, 0XFF,
|
||||
0XFF, 0XFF, 0X80, 0X3F, 0XFF, 0XFF, 0XFF, 0XF0, 0X1F, 0XFF, 0XFF, 0XFF,
|
||||
0XFE, 0X0F, 0XFF, 0XFF, 0XFF, 0XFF, 0X0F, 0XFF, 0XFF, 0XFF, 0XFF, 0X07,
|
||||
0XFF, 0XFF, 0XFF, 0XFE, 0X03, 0XFF, 0XFF, 0XFF, 0XF8, 0X00, 0XFF, 0XFF,
|
||||
0XFF, 0XF0, 0X00, 0X3F, 0XFF, 0XFF, 0XE0, 0X00, 0X7F, 0XFF, 0XFF, 0X80,
|
||||
0X00, 0XFF, 0XFF, 0XFE, 0X00, 0X01, 0XFF, 0XFF, 0XE0, 0X00, 0X03, 0XFF,
|
||||
0XFF, 0XF0, 0X00, 0X03, 0XFF, 0XFF, 0XF8, 0X00, 0X03, 0XFF, 0XFF, 0XF8,
|
||||
0X00, 0X07, 0XFF, 0XFF, 0XF8, 0X00, 0X07, 0XFF, 0XBF, 0XF8, 0X00, 0X07,
|
||||
0XFF, 0X3F, 0XF8, 0X00, 0X0F, 0XFE, 0X1F, 0XF8, 0X00, 0X0F, 0XFC, 0X1F,
|
||||
0XF8, 0X00, 0X0F, 0XE0, 0X0F, 0XF8, 0X00, 0X0F, 0X00, 0X07, 0XFC, 0X00,
|
||||
0X00, 0X00, 0X01, 0XFC, 0X00, 0X00, 0X00, 0X00, 0XFC, 0X00, 0X00, 0X00,
|
||||
0X00, 0X78, 0X00, 0X00, 0X00, 0X00, 0X18, 0X00 };
|
||||
0X00, 0X00, 0X06, 0X00, 0X00, 0X00, 0X00, 0X0F, 0X00, 0X00, 0X00, 0X00,
|
||||
0X0F, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X3F, 0X80,
|
||||
0X00, 0X00, 0X00, 0X7F, 0X80, 0X00, 0X00, 0X00, 0X7F, 0X80, 0X00, 0X00,
|
||||
0X00, 0XFF, 0XC0, 0X00, 0X00, 0X00, 0XFF, 0XC0, 0X00, 0X00, 0X01, 0XFF,
|
||||
0XC0, 0X00, 0X00, 0X01, 0XFF, 0XC0, 0X00, 0XFF, 0XF9, 0XFF, 0XC0, 0X00,
|
||||
0XFF, 0XFD, 0XFF, 0XC0, 0X00, 0X7F, 0XFF, 0XFF, 0XC0, 0X00, 0X7F, 0XFF,
|
||||
0XFF, 0XFF, 0X80, 0X3F, 0XFF, 0XFF, 0XFF, 0XF0, 0X1F, 0XFF, 0XFF, 0XFF,
|
||||
0XFE, 0X0F, 0XFF, 0XFF, 0XFF, 0XFF, 0X0F, 0XFF, 0XFF, 0XFF, 0XFF, 0X07,
|
||||
0XFF, 0XFF, 0XFF, 0XFE, 0X03, 0XFF, 0XFF, 0XFF, 0XF8, 0X00, 0XFF, 0XFF,
|
||||
0XFF, 0XF0, 0X00, 0X3F, 0XFF, 0XFF, 0XE0, 0X00, 0X7F, 0XFF, 0XFF, 0X80,
|
||||
0X00, 0XFF, 0XFF, 0XFE, 0X00, 0X01, 0XFF, 0XFF, 0XE0, 0X00, 0X03, 0XFF,
|
||||
0XFF, 0XF0, 0X00, 0X03, 0XFF, 0XFF, 0XF8, 0X00, 0X03, 0XFF, 0XFF, 0XF8,
|
||||
0X00, 0X07, 0XFF, 0XFF, 0XF8, 0X00, 0X07, 0XFF, 0XBF, 0XF8, 0X00, 0X07,
|
||||
0XFF, 0X3F, 0XF8, 0X00, 0X0F, 0XFE, 0X1F, 0XF8, 0X00, 0X0F, 0XFC, 0X1F,
|
||||
0XF8, 0X00, 0X0F, 0XE0, 0X0F, 0XF8, 0X00, 0X0F, 0X00, 0X07, 0XFC, 0X00,
|
||||
0X00, 0X00, 0X01, 0XFC, 0X00, 0X00, 0X00, 0X00, 0XFC, 0X00, 0X00, 0X00,
|
||||
0X00, 0X78, 0X00, 0X00, 0X00, 0X00, 0X18, 0X00};
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void setup() {
|
|||
|
||||
void loop() {
|
||||
uint32_t t = millis();
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
double xx, yy, zz;
|
||||
xx = event.acceleration.x;
|
||||
yy = event.acceleration.y;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ void setup() {
|
|||
|
||||
void loop() {
|
||||
uint32_t t = millis();
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
double xx, yy, zz;
|
||||
xx = event.acceleration.x;
|
||||
yy = event.acceleration.y;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void setup() {
|
|||
pixeldust->randomize(); // Initialize random snowflake positions
|
||||
|
||||
// get the first accelerometer reading
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
@ -69,7 +69,7 @@ void loop() {
|
|||
|
||||
// we dont want to read the accel while DMA occurs, because it seems to be :(
|
||||
// so read it now, and we'll use it later
|
||||
arcada.accel.getEvent(&event);
|
||||
arcada.accel->getEvent(&event);
|
||||
|
||||
// Erase canvas and draw new snowflake positions
|
||||
memset(framebuffer, 0x00, width*height*2); // clear the frame buffer
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name=Adafruit Arcada Library
|
||||
version=2.1.6
|
||||
version=2.5.10
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=This is a library to abstract away arcade/gameplay display, sounds and controls.
|
||||
|
|
@ -7,3 +7,4 @@ paragraph=This is a library to abstract away arcade/gameplay/UI display and cont
|
|||
category=Display
|
||||
url=https://github.com/adafruit/Adafruit_Arcada
|
||||
architectures=*
|
||||
depends=Adafruit GFX Library, Adafruit FreeTouch Library, Adafruit ImageReader Library, Adafruit NeoPixel, Adafruit ADT7410 Library, Adafruit ST7735 and ST7789 Library, Adafruit ILI9341, Adafruit SPIFlash, Adafruit LIS3DH, Adafruit ZeroTimer Library, Adafruit TouchScreen, Adafruit LSM6DS, Adafruit LIS3MDL, Adafruit BMP280 Library, Adafruit SHT31 Library, Adafruit APDS9960 Library, Adafruit MSA301, Adafruit EPD, Adafruit PixelDust, ArduinoJson, Adafruit WavePlayer Library, Adafruit TinyUSB Library, SdFat - Adafruit Fork, Adafruit Circuit Playground, Adafruit Unified Sensor, Adafruit BusIO, Audio - Adafruit Fork, CircularBuffer
|
||||
|
|
|
|||
Loading…
Reference in a new issue