mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-06-12 20:04:15 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
c69f2734e8
@ -27,7 +27,7 @@ addons:
|
||||
- diffutils
|
||||
- dos2unix
|
||||
- doxygen
|
||||
after_success:
|
||||
after_script:
|
||||
bash util/travis_compiled_push.sh
|
||||
notifications:
|
||||
webhooks:
|
||||
|
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@ -1,6 +1,11 @@
|
||||
// Suggested extensions
|
||||
{
|
||||
"recommendations": [
|
||||
"EditorConfig.EditorConfig"
|
||||
"EditorConfig.EditorConfig",
|
||||
"xaver.clang-format",
|
||||
"ms-vscode.cpptools",
|
||||
"bierner.github-markdown-preview",
|
||||
"donjayamanne.git-extension-pack",
|
||||
"CoenraadS.bracket-pair-colorizer-2"
|
||||
]
|
||||
}
|
||||
|
@ -8,8 +8,17 @@ Our users, contributors, and collaborators are expected to treat each other with
|
||||
|
||||
* The use of sexualized language or imagery
|
||||
* Unwelcome advances, sexual or otherwise
|
||||
* Deliberate intimidation, stalking, or following
|
||||
* Insults or derogatory comments, or personal or political attacks
|
||||
* Publishing others’ private information without explicit permission
|
||||
* Sustained disruption of talks or other events
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
* Advocating for, or encouraging, any of the above behaviour
|
||||
|
||||
If someone is violating this Code of Conduct you may email hello@qmk.fm to bring your concern to the Members. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
# Reporting
|
||||
|
||||
If someone is violating this Code of Conduct, please email hello@qmk.fm or reach out to one of the Collaborators to bring it to our attention. All complaints will be reviewed and investigated.
|
||||
|
||||
QMK will seek to use the least punitive means available to resolve an issue. If the circumstances require asking an offender to leave, we will do that.
|
||||
|
||||
Reports will be taken and kept in strict confidence. You will not be required to confront an offender directly.
|
||||
|
10
Makefile
10
Makefile
@ -20,7 +20,10 @@ endif
|
||||
override SILENT := false
|
||||
|
||||
ifndef SUB_IS_SILENT
|
||||
QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
|
||||
ifndef SKIP_GIT
|
||||
QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
|
||||
endif
|
||||
|
||||
ifneq ($(QMK_VERSION),)
|
||||
$(info QMK Firmware $(QMK_VERSION))
|
||||
endif
|
||||
@ -94,6 +97,7 @@ $(eval $(call NEXT_PATH_ELEMENT))
|
||||
# endif
|
||||
|
||||
define GET_KEYBOARDS
|
||||
ifndef ALT_GET_KEYBOARDS
|
||||
All_RULES_MK := $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/rules.mk))
|
||||
All_RULES_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/rules.mk))
|
||||
All_RULES_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/*/rules.mk))
|
||||
@ -105,6 +109,9 @@ define GET_KEYBOARDS
|
||||
KEYMAPS_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/*/*/keymaps/*/rules.mk))
|
||||
|
||||
KEYBOARDS := $$(sort $$(filter-out $$(KEYMAPS_MK), $$(All_RULES_MK)))
|
||||
else
|
||||
KEYBOARDS := $(shell find keyboards/ -type f -iname "rules.mk" | grep -v keymaps | sed 's!keyboards/\(.*\)/rules.mk!\1!' | sort | uniq)
|
||||
endif
|
||||
endef
|
||||
|
||||
$(eval $(call GET_KEYBOARDS))
|
||||
@ -541,6 +548,7 @@ ifndef SKIP_GIT
|
||||
if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 1 --init lib/chibios; fi
|
||||
if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 1 --init lib/chibios-contrib; fi
|
||||
if [ ! -e lib/ugfx ]; then git submodule sync lib/ugfx && git submodule update --depth 1 --init lib/ugfx; fi
|
||||
if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 1 --init lib/lufa; fi
|
||||
git submodule status --recursive 2>/dev/null | \
|
||||
while IFS= read -r x; do \
|
||||
case "$$x" in \
|
||||
|
12
bin/qmk
12
bin/qmk
@ -38,7 +38,7 @@ with open('requirements.txt', 'r') as fd:
|
||||
|
||||
# Figure out our version
|
||||
command = ['git', 'describe', '--abbrev=6', '--dirty', '--always', '--tags']
|
||||
result = subprocess.run(command, universal_newlines=True, capture_output=True)
|
||||
result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
if result.returncode == 0:
|
||||
os.environ['QMK_VERSION'] = 'QMK ' + result.stdout.strip()
|
||||
@ -47,7 +47,7 @@ else:
|
||||
|
||||
# Setup the CLI
|
||||
import milc
|
||||
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}ψ{style_reset_all}'
|
||||
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'
|
||||
|
||||
# If we were invoked as `qmk <cmd>` massage sys.argv into `qmk-<cmd>`.
|
||||
# This means we can't accept arguments to the qmk script itself.
|
||||
@ -94,4 +94,10 @@ else:
|
||||
exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
milc.cli()
|
||||
return_code = milc.cli()
|
||||
if return_code is False:
|
||||
exit(1)
|
||||
elif return_code is not True and isinstance(return_code, int) and return_code < 256:
|
||||
exit(return_code)
|
||||
else:
|
||||
exit(0)
|
||||
|
@ -267,20 +267,21 @@ ifeq ($(strip $(ENCODER_ENABLE)), yes)
|
||||
OPT_DEFS += -DENCODER_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(HAPTIC_ENABLE)), DRV2605L)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/haptic
|
||||
SRC += haptic.c
|
||||
HAPTIC_ENABLE ?= no
|
||||
ifneq ($(strip $(HAPTIC_ENABLE)),no)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/haptic
|
||||
SRC += haptic.c
|
||||
OPT_DEFS += -DHAPTIC_ENABLE
|
||||
endif
|
||||
|
||||
ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
|
||||
SRC += DRV2605L.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
OPT_DEFS += -DHAPTIC_ENABLE
|
||||
OPT_DEFS += -DDRV2605L
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(HAPTIC_ENABLE)), SOLENOID)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/haptic
|
||||
SRC += haptic.c
|
||||
ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
|
||||
SRC += solenoid.c
|
||||
OPT_DEFS += -DHAPTIC_ENABLE
|
||||
OPT_DEFS += -DSOLENOID_ENABLE
|
||||
endif
|
||||
|
||||
@ -358,3 +359,9 @@ ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
|
||||
OPT_DEFS += -DSPACE_CADET_ENABLE
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/dip_switch.c
|
||||
OPT_DEFS += -DDIP_SWITCH_ENABLE
|
||||
endif
|
||||
|
53
docs/ChangeLog/20190830.md
Normal file
53
docs/ChangeLog/20190830.md
Normal file
@ -0,0 +1,53 @@
|
||||
# QMK Breaking Change - 2019 Aug 30
|
||||
|
||||
Four times a year QMK runs a process for merging Breaking Changes. A Breaking Change is any change which modifies how QMK behaves in a way that is incompatible or potentially dangerous. We limit these changes to 4 times per year so that users can have confidence that updating their QMK tree will not break their keymaps.
|
||||
|
||||
This document marks the inaugural Breaking Change merge. A list of changes follows.
|
||||
|
||||
## Core code formatting with clang-format
|
||||
|
||||
* All core files (`drivers/`, `quantum/`, `tests/`, and `tmk_core/`) have been formatted with clang-format
|
||||
* A travis process to reformat PR's on merge has been instituted
|
||||
* You can use the new CLI command `qmk cformat` to format before submitting your PR if you wish.
|
||||
|
||||
## LUFA USB descriptor cleanup
|
||||
|
||||
* Some code cleanups related to the USB HID descriptors on AVR keyboards, to make them easier to read and understand
|
||||
* More information: see https://github.com/qmk/qmk_firmware/pull/4871
|
||||
* No behaviour changes anticipated and no keymaps modified
|
||||
|
||||
## Migrating `ACTION_LAYER_MOMENTARY()` entries in `fn_actions` to `MO()` keycodes
|
||||
|
||||
* `fn_actions` is deprecated, and its functionality has been superseded by direct keycodes and `process_record_user()`
|
||||
* The end result of removing this obsolete feature should result in a decent reduction in firmware size and code complexity
|
||||
* All keymaps affected are recommended to switch away from `fn_actions` in favour of the [custom keycode](https://docs.qmk.fm/#/custom_quantum_functions) and [macro](https://docs.qmk.fm/#/feature_macros) features
|
||||
|
||||
## Update Atreus to current code conventions
|
||||
|
||||
* Duplicate include guards have bypassed the expected header processing behavior
|
||||
* All keymaps affected are recommended to remove duplication of `<keyboard>/config.h` to `<keyboard>/keymaps/<user>/config.h` and only provide overrides at the keymap level
|
||||
|
||||
## Backport changes to keymap language files from ZSA fork
|
||||
|
||||
* Fixes an issue in the `keymap_br_abnt2.h` file that includes the wrong source (`keymap_common.h` instead of `keymap.h`)
|
||||
* Updates the `keymap_swedish.h` file to be specific to swedish, and not just "nordic" in general.
|
||||
* Any keymaps using this will need to remove `NO_*` and replace it with `SE_*`.
|
||||
|
||||
## Update repo to use LUFA as a git submodule
|
||||
|
||||
* `/lib/LUFA` removed from the repo
|
||||
* LUFA set as a submodule, pointing to qmk/lufa
|
||||
* This should allow more flexibility with LUFA, and allow us to keep the sub-module up to date, a lot more easily. It was ~2 years out of date with no easy path to fix that. This prevents that from being an issue in the future
|
||||
|
||||
## Migrating `ACTION_BACKLIGHT_*()` entries in `fn_actions` to `BL_` keycodes
|
||||
|
||||
* `fn_actions` is deprecated, and its functionality has been superseded by direct keycodes and `process_record_user()`
|
||||
* All keymaps using these actions have had the relevant `KC_FN*` keys replaced with the equivalent `BL_*` keys
|
||||
* If you currently use `KC_FN*` you will need to replace `fn_actions` with the [custom keycode](https://docs.qmk.fm/#/custom_quantum_functions) and [macro](https://docs.qmk.fm/#/feature_macros) features
|
||||
|
||||
## Remove `KC_DELT` alias in favor of `KC_DEL`
|
||||
|
||||
* `KC_DELT` was a redundant, undocumented alias for `KC_DELETE`
|
||||
* It has been removed and all its uses replaced with the more common `KC_DEL` alias
|
||||
* Around 90 keymaps (mostly for ErgoDox boards) have been modified as a result
|
||||
|
@ -13,11 +13,15 @@
|
||||
* [How to Use Github](getting_started_github.md)
|
||||
* [Getting Help](getting_started_getting_help.md)
|
||||
|
||||
* [Breaking Changes](breaking_changes.md)
|
||||
* [2019 Aug 30](ChangeLog/20190830.md)
|
||||
|
||||
* [FAQ](faq.md)
|
||||
* [General FAQ](faq_general.md)
|
||||
* [Build/Compile QMK](faq_build.md)
|
||||
* [Debugging/Troubleshooting QMK](faq_debug.md)
|
||||
* [Keymap](faq_keymap.md)
|
||||
* [Driver Installation with Zadig](driver_installation_zadig.md)
|
||||
|
||||
* Detailed Guides
|
||||
* [Install Build Tools](getting_started_build_tools.md)
|
||||
@ -59,6 +63,7 @@
|
||||
* [Combos](feature_combo.md)
|
||||
* [Command](feature_command.md)
|
||||
* [Debounce API](feature_debounce_type.md)
|
||||
* [DIP Switch](feature_dip_switch.md)
|
||||
* [Dynamic Macros](feature_dynamic_macros.md)
|
||||
* [Encoders](feature_encoders.md)
|
||||
* [Grave Escape](feature_grave_esc.md)
|
||||
|
108
docs/breaking_changes.md
Normal file
108
docs/breaking_changes.md
Normal file
@ -0,0 +1,108 @@
|
||||
# Breaking Changes
|
||||
|
||||
This document describes QMK's Breaking Change process. A Breaking Change is any change which modifies how QMK behaves in a way that in incompatible or potentially dangerous. We limit these changes so that users can have confidence that updating their QMK tree will not break their keymaps.
|
||||
|
||||
The breaking change period is when we will merge PR's that change QMK in dangerous or unexpected ways. There is a built-in period of testing so we are confident that any problems caused are rare or unable to be predicted.
|
||||
|
||||
## What has been included in past Breaking Changes?
|
||||
|
||||
* [2019 Aug 30](ChangeLog/20190830.md)
|
||||
|
||||
## When is the next Breaking Change?
|
||||
|
||||
The next Breaking Change is scheduled for Nov 29.
|
||||
|
||||
### Important Dates
|
||||
|
||||
* [ ] 2019 Oct 04 - `future` is created. It will be rebased weekly.
|
||||
* [ ] 2019 Nov 01 - `future` closed to new PR's.
|
||||
* [ ] 2019 Nov 01 - Call for testers.
|
||||
* [ ] 2019 Nov 27 - `master` is locked, no PR's merged.
|
||||
* [ ] 2019 Nov 29 - Merge `future` to `master`.
|
||||
* [ ] 2019 Nov 30 - `master` is unlocked. PR's can be merged again.
|
||||
|
||||
## What changes will be included?
|
||||
|
||||
To see a list of breaking change candidates you can look at the [`breaking_change` label](https://github.com/qmk/qmk_firmware/pulls?q=is%3Aopen+label%3Abreaking_change+is%3Apr). New changes might be added between now and when `future` is closed, and a PR with that label applied is not guaranteed to be merged.
|
||||
|
||||
If you want your breaking change to be included in this round you need to create a PR with the `breaking_change` label and have it accepted before `future` closes. After `future` closes no new breaking changes will be accepted.
|
||||
|
||||
Criteria for acceptance:
|
||||
|
||||
* PR is complete and ready to merge
|
||||
* PR has a ChangeLog
|
||||
|
||||
# Checklists
|
||||
|
||||
This section documents various processes we use when running the Breaking Changes process.
|
||||
|
||||
## Rebase `future` from `master`
|
||||
|
||||
This is run every Friday while `future` is open.
|
||||
|
||||
Process:
|
||||
|
||||
```
|
||||
cd qmk_firmware
|
||||
git checkout master
|
||||
git pull --ff-only
|
||||
git checkout future
|
||||
git rebase master
|
||||
git push --force
|
||||
```
|
||||
|
||||
## 8 Weeks Before Merge
|
||||
|
||||
* `qmk_firmware` git commands
|
||||
* [ ] `git checkout master`
|
||||
* [ ] `git pull --ff-only`
|
||||
* [ ] `git checkout -b future`
|
||||
* [ ] Edit `readme.md`
|
||||
* [ ] Add a big notice at the top that this is a testing branch.
|
||||
* [ ] Include a link to this document
|
||||
* [ ] `git commit -m 'Branch point for <DATE> Breaking Change'`
|
||||
* [ ] `git tag breakpoint_<YYYY>_<MM>_<DD>`
|
||||
* [ ] `git tag <next_version>` # Prevent the breakpoint tag from confusing version incrementing
|
||||
* [ ] `git push origin future`
|
||||
* [ ] `git push --tags`
|
||||
* GitHub Actions
|
||||
* [ ] Switch all [breaking_change PR's](https://github.com/qmk/qmk_firmware/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+label%3Abreaking_change) to `future`
|
||||
* [ ] Any that have a ChangeLog entry may be merged immediately.
|
||||
|
||||
## 4 Weeks Before Merge
|
||||
|
||||
* `future` is now closed to new PR's, only fixes for current PR's may be merged
|
||||
* Post call for testers
|
||||
* [ ] Discord
|
||||
* [ ] GitHub PR
|
||||
* [ ] https://reddit.com/r/olkb
|
||||
|
||||
## 1 Week Before Merge
|
||||
|
||||
* Announce that master will be closed from <2 Days Before> to <Day of Merge>
|
||||
* [ ] Discord
|
||||
* [ ] GitHub PR
|
||||
* [ ] https://reddit.com/r/olkb
|
||||
|
||||
## 2 Days Before Merge
|
||||
|
||||
* Announce that master is closed for 2 days
|
||||
* [ ] Discord
|
||||
* [ ] GitHub PR
|
||||
* [ ] https://reddit.com/r/olkb
|
||||
|
||||
## Day Of Merge
|
||||
|
||||
* `qmk_firmware` git commands
|
||||
* [ ] `git checkout future`
|
||||
* [ ] `git pull --ff-only`
|
||||
* [ ] `git rebase origin/master`
|
||||
* [ ] Edit `readme.md`
|
||||
* [ ] Remove the notes about `future`
|
||||
* [ ] Roll up the ChangeLog into one file.
|
||||
* [ ] `git commit -m 'Merge point for <DATE> Breaking Change'`
|
||||
* [ ] `git push origin future`
|
||||
* Github Actions
|
||||
* [ ] Create a PR for `future`
|
||||
* [ ] Make sure travis comes back clean
|
||||
* [ ] Merge `future` PR
|
25
docs/cli.md
25
docs/cli.md
@ -6,7 +6,8 @@ This page describes how to setup and use the QMK CLI.
|
||||
|
||||
The QMK CLI makes building and working with QMK keyboards easier. We have provided a number of commands to help you work with QMK:
|
||||
|
||||
* `qmk compile-json`
|
||||
* `qmk compile`
|
||||
* `qmk doctor`
|
||||
|
||||
# Setup
|
||||
|
||||
@ -20,12 +21,28 @@ You may want to add this to your `.profile`, `.bash_profile`, `.zsh_profile`, or
|
||||
|
||||
# Commands
|
||||
|
||||
## `qmk compile-json`
|
||||
## `qmk compile`
|
||||
|
||||
This command allows you to compile JSON files you have downloaded from <https://config.qmk.fm>.
|
||||
This command allows you to compile firmware from any directory. You can compile JSON exports from <https://config.qmk.fm> or compile keymaps in the repo.
|
||||
|
||||
**Usage for Configurator Exports**:
|
||||
|
||||
```
|
||||
qmk compile <configuratorExport.json>
|
||||
```
|
||||
|
||||
**Usage for Keymaps**:
|
||||
|
||||
```
|
||||
qmk compile -kb <keyboard_name> -km <keymap_name>
|
||||
```
|
||||
|
||||
## `qmk cformat`
|
||||
|
||||
This command formats C code using clang-format. Run it with no arguments to format all core code, or pass filenames on the command line to run it on specific files.
|
||||
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
qmk compile-json mine.json
|
||||
qmk cformat [file1] [file2] [...] [fileN]
|
||||
```
|
||||
|
@ -76,7 +76,7 @@ This is a C header file that is one of the first things included, and will persi
|
||||
* `#define B7_AUDIO`
|
||||
* enables audio on pin B7 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO)
|
||||
* `#define BACKLIGHT_PIN B7`
|
||||
* pin of the backlight - `B5`, `B6`, `B7` and `C6` (and `D4` on ATmega32A) use hardware PWM, others use software implementation
|
||||
* pin of the backlight
|
||||
* `#define BACKLIGHT_LEVELS 3`
|
||||
* number of levels your backlight will have (maximum 15 excluding off)
|
||||
* `#define BACKLIGHT_BREATHING`
|
||||
@ -91,8 +91,10 @@ This is a C header file that is one of the first things included, and will persi
|
||||
* tries to keep switch state consistent with keyboard LED state
|
||||
* `#define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)`
|
||||
* key combination that allows the use of magic commands (useful for debugging)
|
||||
* `#define USB_MAX_POWER_CONSUMPTION`
|
||||
* `#define USB_MAX_POWER_CONSUMPTION 500`
|
||||
* sets the maximum power (in mA) over USB for the device (default: 500)
|
||||
* `#define USB_POLLING_INTERVAL_MS 10`
|
||||
* sets the USB polling rate in milliseconds for the keyboard, mouse, and shared (NKRO/media keys) interfaces
|
||||
* `#define F_SCL 100000L`
|
||||
* sets the I2C clock rate speed for keyboards using I2C. The default is `400000L`, except for keyboards using `split_common`, where the default is `100000L`.
|
||||
|
||||
|
@ -297,8 +297,8 @@ This runs code every time that the layers get changed. This can be useful for l
|
||||
This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example
|
||||
|
||||
```c
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
switch (biton32(state)) {
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
switch (get_highest_layer(state)) {
|
||||
case _RAISE:
|
||||
rgblight_setrgb (0x00, 0x00, 0xFF);
|
||||
break;
|
||||
@ -320,8 +320,8 @@ uint32_t layer_state_set_user(uint32_t state) {
|
||||
```
|
||||
### `layer_state_set_*` Function Documentation
|
||||
|
||||
* Keyboard/Revision: `uint32_t layer_state_set_kb(uint32_t state)`
|
||||
* Keymap: `uint32_t layer_state_set_user(uint32_t state)`
|
||||
* Keyboard/Revision: `layer_state_t layer_state_set_kb(layer_state_t state)`
|
||||
* Keymap: `layer_state_t layer_state_set_user(layer_state_t state)`
|
||||
|
||||
|
||||
The `state` is the bitmask of the active layers, as explained in the [Keymap Overview](keymap.md#keymap-layer-status)
|
||||
@ -377,8 +377,8 @@ void keyboard_post_init_user(void) {
|
||||
The above function will use the EEPROM config immediately after reading it, to set the default layer's RGB color. The "raw" value of it is converted in a usable structure based on the "union" that you created above.
|
||||
|
||||
```c
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
switch (biton32(state)) {
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
switch (get_highest_layer(state)) {
|
||||
case _RAISE:
|
||||
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_magenta(); rgblight_mode_noeeprom(1); }
|
||||
break;
|
||||
|
42
docs/driver_installation_zadig.md
Normal file
42
docs/driver_installation_zadig.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Bootloader Driver Installation with Zadig
|
||||
|
||||
QMK presents itself to the host as a regular HID keyboard device, and as such requires no special drivers. However, in order to flash your keyboard on Windows, the bootloader device that appears when you reset the board often *does*.
|
||||
|
||||
There are two notable exceptions: the Caterina bootloader, usually seen on Pro Micros, and the Halfkay bootloader shipped with PJRC Teensys, appear as a serial port and a generic HID device respectively, and so do not require a driver.
|
||||
|
||||
We recommend the use of the [Zadig](https://zadig.akeo.ie/) utility. If you have set up the development environment with Msys2 or WSL, the `qmk_install.sh` script will have asked if you want it to install the drivers for you.
|
||||
|
||||
## Installation
|
||||
|
||||
Place your keyboard into the bootloader mode, either by hitting the `RESET` keycode (which may be on a different layer), or by pressing the reset switch usually located on the underside of the board. If your keyboard has neither, try holding Escape, or Space+`B`, as you plug it in (see the [Bootmagic](feature_bootmagic.md) docs for more details).
|
||||
Some keyboards may have specific instructions for entering the bootloader, for example the [Bootmagic Lite](feature_bootmagic.md#bootmagic-lite) key (Escape) might be on a different key, such as Left Control. Refer to the board's README if you are unsure.
|
||||
|
||||
Zadig will automatically detect the bootloader device. You may sometimes need to check **Options -> List All Devices**.
|
||||
- For keyboards with Atmel AVR MCUs, the bootloader will be named something similar to `ATm32U4DFU`, and have a Vendor ID of `03EB`.
|
||||
- USBasp bootloaders will appear as `USBasp`, with a VID/PID of `16C0:05DC`.
|
||||
- AVR keyboards flashed with the QMK-DFU bootloader will be named `<keyboard name> Bootloader` and will also have the VID `03EB`.
|
||||
- For most ARM keyboards, it will be called `STM32 BOOTLOADER`, and have a VID/PID of `0483:DF11`.
|
||||
|
||||
!> If Zadig lists one or more devices with the `HidUsb` driver, your keyboard is probably not in bootloader mode. The arrow will be colored orange and you will be asked to confirm modifying a system driver. **Do not** proceed if this is the case!
|
||||
|
||||
If the arrow appears green, select the driver, and click **Install Driver**. The `libusb-win32` driver will usually work for AVR, and `WinUSB` for ARM, but if you still cannot flash the board, try installing a different driver from the list.
|
||||
|
||||

|
||||
|
||||
Finally, unplug and replug the keyboard to make sure the new driver has been loaded. If you are using the QMK Toolbox to flash, exit and restart it too, as it can sometimes fail to recognize the driver change.
|
||||
|
||||
## Recovering from Installation to Wrong Device
|
||||
|
||||
If you find that you can no longer type with the keyboard, you may have installed the driver onto the keyboard itself instead of the bootloader. You can easily confirm this in Zadig - a healthy keyboard has the `HidUsb` driver installed on all of its interfaces:
|
||||
|
||||

|
||||
|
||||
Open the Device Manager and look for a device that looks like your keyboard.
|
||||
|
||||

|
||||
|
||||
Right-click it and hit **Uninstall device**. Make sure to tick **Delete the driver software for this device** first.
|
||||
|
||||

|
||||
|
||||
Click **Action -> Scan for hardware changes**. At this point, you should be able to type again. Double check in Zadig that the keyboard device(s) are using the `HidUsb` driver. If so, you're all done, and your board should be functional again!
|
@ -75,14 +75,11 @@ Pro Micro (Atmega32u4), make sure to include `CONFIG_USB_ACM=y`. Other devices m
|
||||
|
||||
## Unknown Device for DFU Bootloader
|
||||
|
||||
Issues encountered when flashing keyboards on Windows are most often due to having the wrong drivers installed for the bootloader.
|
||||
Issues encountered when flashing keyboards on Windows are most often due to having the wrong drivers installed for the bootloader, or none at all.
|
||||
|
||||
Re-running the installation script for MSYS2 may help (eg run `util/qmk_install.sh` from MSYS2/WSL) or reinstalling the QMK Toolbox may fix the issue. Alternatively, you can download and run the [`qmk_driver_installer`](https://github.com/qmk/qmk_driver_installer) package.
|
||||
|
||||
If that doesn't work, then you may need to grab the [Zadig Utility](https://zadig.akeo.ie/). Download this, and run it on the system. Then, you will need to reset your board into bootloader mode. After that, locate the device in question. If the device doesn't show up in the list (or nothing shows up in the list), you may need to enable the `List all devices` option in the `Options` menu.
|
||||
|
||||
From here, you will need to know what type of controller the board is using. You may see it listed in the Device Manager as `ATmega32U4` device (which is an AVR board), or an `STM32` device (Which is an ARM board). For AVR boards, use `libusb-win32` for the driver. For ARM boards, use the `WinUSB` driver. Once the correct driver type has been selected, click on the `Replace Driver` button, unplug your board, plug it back in, and reset it again.
|
||||
Re-running the QMK installation script (`./util/qmk_install.sh` from the `qmk_firmware` directory in MSYS2 or WSL) or reinstalling the QMK Toolbox may fix the issue. Alternatively, you can download and run the [`qmk_driver_installer`](https://github.com/qmk/qmk_driver_installer) package manually.
|
||||
|
||||
If that doesn't work, then you may need to download and run Zadig. See [Bootloader Driver Installation with Zadig](driver_installation_zadig.md) for more detailed information.
|
||||
|
||||
## WINAVR is Obsolete
|
||||
It is no longer recommended and may cause some problem.
|
||||
|
@ -184,22 +184,15 @@ Pressing any key during sleep should wake host.
|
||||
|
||||
Arduino Leonardo and micro have **ATMega32U4** and can be used for TMK, though Arduino bootloader may be a problem.
|
||||
|
||||
## Enabling JTAG
|
||||
|
||||
## Using PF4-7 Pins of USB AVR?
|
||||
You need to set JTD bit of MCUCR yourself to use PF4-7 as GPIO. Those pins are configured to serve JTAG function by default. MCUs like ATMega*U* or AT90USB* are affected with this.
|
||||
By default, the JTAG debugging interface is disabled as soon as the keyboard starts up. JTAG-capable MCUs come from the factory with the `JTAGEN` fuse set, and it takes over certain pins of the MCU that the board may be using for the switch matrix, LEDs, etc.
|
||||
|
||||
If you are using Teensy this isn't needed. Teensy is shipped with JTAGEN fuse bit unprogrammed to disable the function.
|
||||
If you would like to keep JTAG enabled, just add the following to your `config.h`:
|
||||
|
||||
See this code.
|
||||
```c
|
||||
#define NO_JTAG_DISABLE
|
||||
```
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
```
|
||||
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hbkb/matrix.c#L67
|
||||
|
||||
And read **26.5.1 MCU Control Register – MCUCR** of ATMega32U4 datasheet.
|
||||
|
||||
|
||||
## Adding LED Indicators of Lock Keys
|
||||
You need your own LED indicators for CapsLock, ScrollLock and NumLock? See this post.
|
||||
|
@ -21,6 +21,8 @@ STARTUP_SONG // plays when the keyboard starts up (audio.c)
|
||||
GOODBYE_SONG // plays when you press the RESET key (quantum.c)
|
||||
AG_NORM_SONG // plays when you press AG_NORM (quantum.c)
|
||||
AG_SWAP_SONG // plays when you press AG_SWAP (quantum.c)
|
||||
CG_NORM_SONG // plays when you press CG_NORM (quantum.c)
|
||||
CG_SWAP_SONG // plays when you press CG_SWAP (quantum.c)
|
||||
MUSIC_ON_SONG // plays when music mode is activated (process_music.c)
|
||||
MUSIC_OFF_SONG // plays when music mode is deactivated (process_music.c)
|
||||
CHROMATIC_SONG // plays when the chromatic music mode is selected (process_music.c)
|
||||
|
@ -30,32 +30,31 @@ You should then be able to use the keycodes below to change the backlight level.
|
||||
|
||||
This feature is distinct from both the [RGB underglow](feature_rgblight.md) and [RGB matrix](feature_rgb_matrix.md) features as it usually allows for only a single colour per switch, though you can obviously use multiple different coloured LEDs on a keyboard.
|
||||
|
||||
Hardware PWM is only supported on certain pins of the MCU, so if the backlighting is not connected to one of them, a software PWM implementation triggered by hardware timer interrupts will be used.
|
||||
|
||||
Hardware PWM is supported according to the following table:
|
||||
|
||||
| Backlight Pin | Hardware timer |
|
||||
|---------------|-------------------------|
|
||||
|`B5` | Timer 1 |
|
||||
|`B6` | Timer 1 |
|
||||
|`B7` | Timer 1 |
|
||||
|`C6` | Timer 3 |
|
||||
|`D4` | Timer 1 (ATmega32A only)|
|
||||
| other | Software PWM |
|
||||
|Backlight Pin|AT90USB64/128|ATmega16/32U4|ATmega16/32U2|ATmega32A|
|
||||
|-------------|-------------|-------------|-------------|---------|
|
||||
|`B5` |Timer 1 |Timer 1 | | |
|
||||
|`B6` |Timer 1 |Timer 1 | | |
|
||||
|`B7` |Timer 1 |Timer 1 |Timer 1 | |
|
||||
|`C4` |Timer 3 | | | |
|
||||
|`C5` |Timer 3 | |Timer 1 | |
|
||||
|`C6` |Timer 3 |Timer 3 |Timer 1 | |
|
||||
|`D4` | | | |Timer 1 |
|
||||
|`D5` | | | |Timer 1 |
|
||||
|
||||
The [audio feature](feature_audio.md) also uses hardware timers. Please refer to the following table to know what hardware timer the software PWM will use depending on the audio configuration:
|
||||
All other pins will use software PWM. If the [Audio](feature_audio.md) feature is disabled or only using one timer, the backlight PWM can be triggered by a hardware timer:
|
||||
|
||||
| Audio Pin(s) | Audio Timer | Software PWM Timer |
|
||||
|--------------|-------------|--------------------|
|
||||
| `C4` | Timer 3 | Timer 1 |
|
||||
| `C5` | Timer 3 | Timer 1 |
|
||||
| `C6` | Timer 3 | Timer 1 |
|
||||
| `B5` | Timer 1 | Timer 3 |
|
||||
| `B6` | Timer 1 | Timer 3 |
|
||||
| `B7` | Timer 1 | Timer 3 |
|
||||
| `Bx` & `Cx` | Timer 1 & 3 | None |
|
||||
|Audio Pin|Audio Timer|Software PWM Timer|
|
||||
|---------|-----------|------------------|
|
||||
|`C4` |Timer 3 |Timer 1 |
|
||||
|`C5` |Timer 3 |Timer 1 |
|
||||
|`C6` |Timer 3 |Timer 1 |
|
||||
|`B5` |Timer 1 |Timer 3 |
|
||||
|`B6` |Timer 1 |Timer 3 |
|
||||
|`B7` |Timer 1 |Timer 3 |
|
||||
|
||||
When all timers are in use for [audio](feature_audio.md), the backlight software PWM will not use a hardware timer, but instead will be triggered during the matrix scan. In this case the backlight doesn't support breathing and might show lighting artifacts (for instance flickering), because the PWM computation might not be called with enough timing precision.
|
||||
When both timers are in use for Audio, the backlight PWM will not use a hardware timer, but will instead be triggered during the matrix scan. In this case, breathing is not supported, and the backlight might flicker, because the PWM computation may not be called with enough timing precision.
|
||||
|
||||
## Configuration
|
||||
|
||||
@ -120,7 +119,8 @@ The breathing effect is the same as in the hardware PWM implementation.
|
||||
|`backlight_step()` |Cycle through backlight levels |
|
||||
|`backlight_increase()` |Increase the backlight level |
|
||||
|`backlight_decrease()` |Decrease the backlight level |
|
||||
|`backlight_level(x)` |Sets the backlight level to specified level |
|
||||
|`backlight_level(x)` |Sets the backlight level, from 0 to |
|
||||
| |`BACKLIGHT_LEVELS` |
|
||||
|`get_backlight_level()` |Return the current backlight level |
|
||||
|`is_backlight_enabled()`|Return whether the backlight is currently on |
|
||||
|
||||
|
@ -64,8 +64,11 @@ Hold down the Bootmagic key (Space by default) and the desired hotkey while plug
|
||||
|`MAGIC_NO_GUI` | |Disable the GUI keys (useful when gaming) |
|
||||
|`MAGIC_UNNO_GUI` | |Enable the GUI keys |
|
||||
|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides (for macOS)|
|
||||
|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Left Alt and Left GUI |
|
||||
|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Left Alt and GUI swap |
|
||||
|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Alt and GUI |
|
||||
|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Alt and GUI swap |
|
||||
|`MAGIC_SWAP_CTL_GUI` |`CG_SWAP`|Swap Ctrl and GUI on both sides (for macOS)|
|
||||
|`MAGIC_UNSWAP_CTL_GUI` |`CG_NORM`|Unswap Ctrl and GUI |
|
||||
|`MAGIC_TOGGLE_CTL_GUI` |`CG_TOGG`|Toggle Ctrl and GUI swap |
|
||||
|`MAGIC_SWAP_BACKSLASH_BACKSPACE` | |Swap `\` and Backspace |
|
||||
|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`| |Unswap `\` and Backspace |
|
||||
|`MAGIC_SWAP_CONTROL_CAPSLOCK` | |Swap Left Control and Caps Lock |
|
||||
@ -76,6 +79,10 @@ Hold down the Bootmagic key (Space by default) and the desired hotkey while plug
|
||||
|`MAGIC_UNSWAP_LALT_LGUI` | |Unswap Left Alt and Left GUI |
|
||||
|`MAGIC_SWAP_RALT_RGUI` | |Swap Right Alt and Right GUI |
|
||||
|`MAGIC_UNSWAP_RALT_RGUI` | |Unswap Right Alt and Right GUI |
|
||||
|`MAGIC_SWAP_LCTL_LGUI` | |Swap Left Control and Left GUI |
|
||||
|`MAGIC_UNSWAP_LCTL_LGUI` | |Unswap Left Control and Left GUI |
|
||||
|`MAGIC_SWAP_RCTL_RGUI` | |Swap Right Control and Right GUI |
|
||||
|`MAGIC_UNSWAP_RCTL_RGUI` | |Unswap Right Control and Right GUI |
|
||||
|
||||
## Configuration
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
The Combo feature is a chording type solution for adding custom actions. It lets you hit multiple keys at once and produce a different effect. For instance, hitting `A` and `S` within the tapping term would hit `ESC` instead, or have it perform even more complex tasks.
|
||||
|
||||
To enable this feature, yu need to add `COMBO_ENABLE = yes` to your `rules.mk`.
|
||||
To enable this feature, you need to add `COMBO_ENABLE = yes` to your `rules.mk`.
|
||||
|
||||
Additionally, in your `config.h`, you'll need to specify the number of combos that you'll be using, by adding `#define COMBO_COUNT 1` (replacing 1 with the number that you're using).
|
||||
<!-- At this time, this is necessary -->
|
||||
|
90
docs/feature_dip_switch.md
Normal file
90
docs/feature_dip_switch.md
Normal file
@ -0,0 +1,90 @@
|
||||
# DIP Switches
|
||||
|
||||
DIP switches are supported by adding this to your `rules.mk`:
|
||||
|
||||
DIP_SWITCH_ENABLE = yes
|
||||
|
||||
and this to your `config.h`:
|
||||
|
||||
```c
|
||||
#define DIP_SWITCH_PINS { B14, A15, A10, B9 }
|
||||
```
|
||||
|
||||
## Callbacks
|
||||
|
||||
The callback functions can be inserted into your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
void dip_switch_update_kb(uint8_t index, bool active) {
|
||||
dip_switch_update_user(index, active);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
or `keymap.c`:
|
||||
|
||||
```c
|
||||
void dip_switch_update_user(uint8_t index, bool active) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
if(active) { audio_on(); } else { audio_off(); }
|
||||
break;
|
||||
case 1:
|
||||
if(active) { clicky_on(); } else { clicky_off(); }
|
||||
break;
|
||||
case 2:
|
||||
if(active) { music_on(); } else { music_off(); }
|
||||
break;
|
||||
case 3:
|
||||
if (active) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_SONG(plover_song);
|
||||
#endif
|
||||
layer_on(_PLOVER);
|
||||
} else {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_SONG(plover_gb_song);
|
||||
#endif
|
||||
layer_off(_PLOVER);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Additionally, we support bit mask functions which allow for more complex handling.
|
||||
|
||||
|
||||
```c
|
||||
void dip_switch_update_mask_kb(uint32_t state) {
|
||||
dip_switch_update_mask_user(state);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
or `keymap.c`:
|
||||
|
||||
```c
|
||||
void dip_switch_update_mask_user(uint32_t state) {
|
||||
if (state & (1UL<<0) && state & (1UL<<1)) {
|
||||
layer_on(_ADJUST); // C on esc
|
||||
} else {
|
||||
layer_off(_ADJUST);
|
||||
}
|
||||
if (state & (1UL<<0)) {
|
||||
layer_on(_TEST_A); // A on ESC
|
||||
} else {
|
||||
layer_off(_TEST_A);
|
||||
}
|
||||
if (state & (1UL<<1)) {
|
||||
layer_on(_TEST_B); // B on esc
|
||||
} else {
|
||||
layer_off(_TEST_B);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Hardware
|
||||
|
||||
One side of the DIP switch should be wired directly to the pin on the MCU, and the other side to ground. It should not matter which side is connected to which, as it should be functionally the same.
|
@ -20,6 +20,15 @@ Additionally, the resolution can be specified in the same file (the default & su
|
||||
|
||||
#define ENCODER_RESOLUTION 4
|
||||
|
||||
## Split Keyboards
|
||||
|
||||
If you are using different pinouts for the encoders on each half of a split keyboard, you can define the pinout for the right half like this:
|
||||
|
||||
```c
|
||||
#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
|
||||
#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
|
||||
```
|
||||
|
||||
## Callbacks
|
||||
|
||||
The callback functions can be inserted into your `<keyboard>.c`:
|
||||
|
@ -31,7 +31,7 @@ This enables the feature and the `OLED_DRIVER_ENABLE` define. Then in your `keym
|
||||
void oled_task_user(void) {
|
||||
// Host Keyboard Layer Status
|
||||
oled_write_P(PSTR("Layer: "), false);
|
||||
switch (biton32(layer_state)) {
|
||||
switch (get_highest_layer(layer_state)) {
|
||||
case _QWERTY:
|
||||
oled_write_P(PSTR("Default\n"), false);
|
||||
break;
|
||||
@ -96,17 +96,19 @@ void oled_task_user(void) {
|
||||
|
||||
## Basic Configuration
|
||||
|
||||
| Define | Default | Description |
|
||||
|------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------|
|
||||
| `OLED_DISPLAY_ADDRESS` | `0x3C` | The i2c address of the OLED Display |
|
||||
| `OLED_FONT_H` | `"glcdfont.c"` | The font code file to use for custom fonts |
|
||||
| `OLED_FONT_START` | `0` | The starting characer index for custom fonts |
|
||||
| `OLED_FONT_END` | `224` | The ending characer index for custom fonts |
|
||||
| `OLED_FONT_WIDTH` | `6` | The font width |
|
||||
| `OLED_FONT_HEIGHT` | `8` | The font height (untested) |
|
||||
| `OLED_DISABLE_TIMEOUT` | *Not defined* | Disables the built in OLED timeout feature. Useful when implementing custom timeout rules. |
|
||||
| `OLED_IC` | `OLED_IC_SSD1306` | Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. |
|
||||
| `OLED_COLUMN_OFFSET` | `0` | (SH1106 only.) Shift output to the right this many pixels.<br />Useful for 128x64 displays centered on a 132x64 SH1106 IC. |
|
||||
| Define | Default | Description |
|
||||
|----------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------|
|
||||
| `OLED_DISPLAY_ADDRESS` | `0x3C` | The i2c address of the OLED Display |
|
||||
| `OLED_FONT_H` | `"glcdfont.c"` | The font code file to use for custom fonts |
|
||||
| `OLED_FONT_START` | `0` | The starting characer index for custom fonts |
|
||||
| `OLED_FONT_END` | `224` | The ending characer index for custom fonts |
|
||||
| `OLED_FONT_WIDTH` | `6` | The font width |
|
||||
| `OLED_FONT_HEIGHT` | `8` | The font height (untested) |
|
||||
| `OLED_TIMEOUT` | `60000` | Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. |
|
||||
| `OLED_SCROLL_TIMEOUT` | `0` | Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. |
|
||||
| `OLED_SCROLL_TIMEOUT_RIGHT`| *Not defined* | Scroll timeout direction is right when defined, left when undefined. |
|
||||
| `OLED_IC` | `OLED_IC_SSD1306` | Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. |
|
||||
| `OLED_COLUMN_OFFSET` | `0` | (SH1106 only.) Shift output to the right this many pixels.<br />Useful for 128x64 displays centered on a 132x64 SH1106 IC. |
|
||||
|
||||
## 128x64 & Custom sized OLED Displays
|
||||
|
||||
|
@ -374,6 +374,7 @@ These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blo
|
||||
#define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
|
||||
#define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
|
||||
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
|
||||
#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
|
||||
```
|
||||
|
||||
## EEPROM storage
|
||||
|
@ -166,6 +166,13 @@ This allows you to specify a different set of pins for the matrix on the right s
|
||||
|
||||
This allows you to specify a different set of direct pins for the right side.
|
||||
|
||||
```c
|
||||
#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
|
||||
#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
|
||||
```
|
||||
|
||||
This allows you to specify a different set of encoder pins for the right side.
|
||||
|
||||
```c
|
||||
#define RGBLIGHT_SPLIT
|
||||
```
|
||||
|
@ -115,11 +115,11 @@ For instance, let's look at the `layer_state_set_user()` function. You can enab
|
||||
In your `<name.c>` file, you'd want to add this:
|
||||
```c
|
||||
__attribute__ ((weak))
|
||||
uint32_t layer_state_set_keymap (uint32_t state) {
|
||||
layer_state_t layer_state_set_keymap (layer_state_t state) {
|
||||
return state;
|
||||
}
|
||||
|
||||
uint32_t layer_state_set_user (uint32_t state) {
|
||||
layer_state_t layer_state_set_user (layer_state_t state) {
|
||||
state = update_tri_layer_state(state, 2, 3, 5);
|
||||
return layer_state_set_keymap (state);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ QMK has a staggering number of features for building your keyboard. It can take
|
||||
* [Combos](feature_combo.md) - Custom actions for multiple key holds.
|
||||
* [Command](feature_command.md) - Runtime version of bootmagic (Formerly known as "Magic").
|
||||
* [Debounce API](feature_debounce_type.md) - Customization of debouncing algorithms, and the ability to add more/custom debouncing.
|
||||
* [DIP Switch](feature_dip_switch.md) - Toggle switches for customizing board function.
|
||||
* [Dynamic Macros](feature_dynamic_macros.md) - Record and playback macros from the keyboard itself.
|
||||
* [Encoders](feature_encoders.md) - Rotary encoders!
|
||||
* [Grave Escape](feature_grave_esc.md) - Lets you use a single key for Esc and Grave.
|
||||
|
@ -144,6 +144,36 @@ Flashing sequence:
|
||||
3. Flash a .hex file
|
||||
4. Reset the device into application mode (may be done automatically)
|
||||
|
||||
## BootloadHID
|
||||
|
||||
BootloadHID is a USB bootloader for AVR microcontrollers. The uploader tool requires no kernel level driver on Windows and can therefore be run without installing any DLLs.
|
||||
|
||||
To ensure compatibility with the bootloadHID bootloader, make sure this block is present your `rules.mk`:
|
||||
|
||||
# Bootloader
|
||||
# This definition is optional, and if your keyboard supports multiple bootloaders of
|
||||
# different sizes, comment this out, and the correct address will be loaded
|
||||
# automatically (+60). See bootloader.mk for all options.
|
||||
BOOTLOADER = bootloadHID
|
||||
|
||||
Compatible flashers:
|
||||
|
||||
* [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash) (recommended Windows GUI)
|
||||
* [bootloadhid Command Line](https://www.obdev.at/products/vusb/bootloadhid.html) / `:BootloadHID` in QMK (recommended command line)
|
||||
|
||||
Flashing sequence:
|
||||
|
||||
1. Enter the bootloader using any of the following methods:
|
||||
* Tap the `RESET` keycode (may not work on all devices)
|
||||
* Hold the salt key while plugging the keyboard in (usually documented within keyboard readme)
|
||||
2. Wait for the OS to detect the device
|
||||
3. Flash a .hex file
|
||||
4. Reset the device into application mode (may be done automatically)
|
||||
|
||||
or:
|
||||
|
||||
make <keyboard>:<keymap>:bootloadHID
|
||||
|
||||
## STM32
|
||||
|
||||
All STM32 chips come preloaded with a factory bootloader that cannot be modified nor deleted. Some STM32 chips have bootloaders that do not come with USB programming (e.g. STM32F103) but the process is still the same.
|
||||
@ -171,7 +201,5 @@ Flashing sequence:
|
||||
|
||||
There are a number of DFU commands that you can use to flash firmware to a STM32 device:
|
||||
|
||||
* `:dfu-util` - The default command for flashing to STM32 devices.
|
||||
* `:dfu-util-wait` - This works like the default command, but it gives you a (configurable) 10 second timeout before it attempts to flash the firmware. You can use `TIME_DELAY=20` from the command line to change the timeout.
|
||||
* Eg: `make <keyboard>:<keymap>:dfu-util TIME_DELAY=5`
|
||||
* `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.
|
||||
* `:dfu-util` - The default command for flashing to STM32 devices.
|
||||
* `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.
|
||||
|
70
docs/flashing_bootloadhid.md
Normal file
70
docs/flashing_bootloadhid.md
Normal file
@ -0,0 +1,70 @@
|
||||
# BootloadHID Flashing Instructions and Bootloader Information
|
||||
|
||||
ps2avr(GB) boards use an ATmega32A microcontroller and a different bootloader. It is not flashable using the regular QMK methods.
|
||||
|
||||
General flashing sequence:
|
||||
|
||||
1. Enter the bootloader using any of the following methods:
|
||||
* Tap the `RESET` keycode (may not work on all devices)
|
||||
* Hold the salt key while plugging the keyboard in (usually documented within keyboard readme)
|
||||
2. Wait for the OS to detect the device
|
||||
3. Flash a .hex file
|
||||
4. Reset the device into application mode (may be done automatically)
|
||||
|
||||
## bootloadHID Flashing Target
|
||||
|
||||
Using the QMK installation script, detailed [here](newbs_getting_started.md), the required bootloadHID tools should be automatically installed.
|
||||
|
||||
To flash via the command line, use the target `:bootloadHID` by executing the following command:
|
||||
|
||||
make <keyboard>:<keymap>:bootloadHID
|
||||
|
||||
## GUI Flashing
|
||||
|
||||
### Windows
|
||||
1. Download [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash).
|
||||
2. Place your keyboard into reset.
|
||||
3. Ensure the configured VendorID is `16c0` and ProductID is `05df`
|
||||
4. Press the `Find Device` button and ensure that your keyboard is found.
|
||||
5. Press the `Open .hex File` button and locate the `.hex` file you created.
|
||||
6. Press the `Flash Device` button and wait for the process to complete.
|
||||
|
||||
## Command Line Flashing
|
||||
|
||||
1. Place your keyboard into reset.
|
||||
2. Flash the board by typing `bootloadHID -r` followed by the path to your `.hex` file.
|
||||
|
||||
### Windows Manual Installation
|
||||
For MSYS2:
|
||||
1. Download the BootloadHID firmware package from https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz.
|
||||
2. Extract contents using a compatible tool, for example 7-Zip.
|
||||
3. Add to the MSYS path by copying `commandline/bootloadHID.exe` from the extracted archive to your MSYS2 installation, typically `C:\msys64\usr\bin`.
|
||||
|
||||
For native Windows flashing, the `bootloadHID.exe` can be used outside of the MSYS2 environment.
|
||||
|
||||
### Linux Manual Installation
|
||||
1. Install libusb development dependency:
|
||||
```bash
|
||||
# This depends on OS - for Debian the following works
|
||||
sudo apt-get install libusb-dev
|
||||
```
|
||||
2. Download the BootloadHID firmware package:
|
||||
```
|
||||
wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz -O - | tar -xz -C /tmp
|
||||
```
|
||||
3. Build the bootloadHID executable:
|
||||
```
|
||||
cd /tmp/bootloadHID.2012-12-08/commandline/
|
||||
make
|
||||
sudo cp bootloadHID /usr/local/bin
|
||||
```
|
||||
|
||||
### MacOS Manual Installation
|
||||
1. Install Homebrew by typing the following:
|
||||
```
|
||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
```
|
||||
2. Install the following packages:
|
||||
```
|
||||
brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb
|
||||
```
|
@ -14,7 +14,7 @@ The full syntax of the `make` command is `<keyboard_folder>:<keymap>:<target>`,
|
||||
The `<target>` means the following
|
||||
* If no target is given, then it's the same as `all` below
|
||||
* `all` compiles as many keyboard/revision/keymap combinations as specified. For example, `make planck/rev4:default` will generate a single .hex, while `make planck/rev4:all` will generate a hex for every keymap available to the planck.
|
||||
* `dfu`, `teensy`, `avrdude` or `dfu-util`, compile and upload the firmware to the keyboard. If the compilation fails, then nothing will be uploaded. The programmer to use depends on the keyboard. For most keyboards it's `dfu`, but for ChibiOS keyboards you should use `dfu-util`, and `teensy` for standard Teensys. To find out which command you should use for your keyboard, check the keyboard specific readme.
|
||||
* `dfu`, `teensy`, `avrdude`, `dfu-util` or `bootloadHID`, compile and upload the firmware to the keyboard. If the compilation fails, then nothing will be uploaded. The programmer to use depends on the keyboard. For most keyboards it's `dfu`, but for ChibiOS keyboards you should use `dfu-util`, and `teensy` for standard Teensys. To find out which command you should use for your keyboard, check the keyboard specific readme.
|
||||
* **Note**: some operating systems need root access for these commands to work, so in that case you need to run for example `sudo make planck/rev4:default:dfu`.
|
||||
* `clean`, cleans the build output folders to make sure that everything is built from scratch. Run this before normal compilation if you have some unexplainable problems.
|
||||
|
||||
@ -83,7 +83,7 @@ This allows the keyboard to tell the host OS that up to 248 keys are held down a
|
||||
|
||||
`BACKLIGHT_ENABLE`
|
||||
|
||||
This enables your backlight on Timer1 and ports B5, B6, or B7 (for now). You can specify your port by putting this in your `config.h`:
|
||||
This enables the in-switch LED backlighting. You can specify the backlight pin by putting this in your `config.h`:
|
||||
|
||||
#define BACKLIGHT_PIN B7
|
||||
|
||||
|
@ -78,7 +78,7 @@ Do change the `MANUFACTURER`, `PRODUCT`, and `DESCRIPTION` lines to accurately r
|
||||
#define DESCRIPTION A custom keyboard
|
||||
```
|
||||
|
||||
?> Note: On Windows and macOS the `MANUFACTURER`, `PRODUCT`, and `DESCRIPTION` fields will be displayed in the list of USB devices. ?> On Linux these values will not be visible in lsusb by default, since Linux takes the information from the list maintained by [USB ID Repository](http://www.linux-usb.org/usb-ids.html) by default. lsusb will show the information reported by the device when executed with -v option. It is also present in kernel logs after plugging in the device.
|
||||
?> Windows and macOS will display the `MANUFACTURER` and `PRODUCT` in the list of USB devices. `lsusb` on Linux instead takes these from the list maintained by the [USB ID Repository](http://www.linux-usb.org/usb-ids.html) by default. `lsusb -v` will show the values reported by the device, and they are also present in kernel logs after plugging it in.
|
||||
|
||||
### Keyboard Matrix Configuration
|
||||
|
||||
@ -125,7 +125,7 @@ To configure a keyboard where each switch is connected to a separate pin and gro
|
||||
|
||||
### Backlight Configuration
|
||||
|
||||
By default QMK supports backlighting on pins `B5`, `B6`, and `B7`. If you are using one of those you can simply enable it here. For more details see the [Backlight Documentation](feature_backlight.md).
|
||||
QMK supports backlighting on most GPIO pins. A select few of these can be driven by the MCU in hardware. For more details see the [Backlight Documentation](feature_backlight.md).
|
||||
|
||||
```c
|
||||
#define BACKLIGHT_PIN B7
|
||||
@ -134,8 +134,6 @@ By default QMK supports backlighting on pins `B5`, `B6`, and `B7`. If you are us
|
||||
#define BREATHING_PERIOD 6
|
||||
```
|
||||
|
||||
?> You can use backlighting on any pin you like, but you will have to do more work to support that. See the [Backlight Documentation](feature_backlight.md) for more details.
|
||||
|
||||
### Other Configuration Options
|
||||
|
||||
There are a lot of features that can be configured or tuned in `config.h`. You should see the [Config Options](config_options.md) page for more details.
|
||||
|
@ -33,7 +33,11 @@ The firmware does not send actual letters or characters, but only scancodes.
|
||||
Thus, by modifying the firmware, you can only modify what scancode is sent over
|
||||
USB for a given key.
|
||||
|
||||
## 3. What the Operating System Does
|
||||
## 3. What the Event Input/Kernel Does
|
||||
|
||||
The *scancode* is mapped to a *keycode* dependent on the keyboard [60-keyboard.hwdb at Master](https://github.com/systemd/systemd/blob/master/hwdb/60-keyboard.hwdb). Without this mapping, the operating system will not receive a valid keycode and will be unable to do anything useful with that key press.
|
||||
|
||||
## 4. What the Operating System Does
|
||||
|
||||
Once the keycode reaches the operating system, a piece of software has to have
|
||||
it match an actual character thanks to a keyboard layout. For example, if your
|
||||
|
@ -7,7 +7,7 @@ The I2C Master drivers used in QMK have a set of common functions to allow porta
|
||||
|Function |Description |
|
||||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|`void i2c_init(void);` |Initializes the I2C driver. This function should be called once before any transaction is initiated. |
|
||||
|`uint8_t i2c_start(uint8_t address);` |Starts an I2C transaction. Address is the 7-bit slave address without the direction bit. |
|
||||
|`uint8_t i2c_start(uint8_t address, uint16_t timeout);` |Starts an I2C transaction. Address is the 7-bit slave address without the direction bit. |
|
||||
|`uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);` |Transmit data over I2C. Address is the 7-bit slave address without the direction. Returns status of transaction. |
|
||||
|`uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);` |Receive data over I2C. Address is the 7-bit slave address without the direction. Saves number of bytes specified by `length` in `data` array. Returns status of transaction. |
|
||||
|`uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);` |Same as the `i2c_transmit` function but `regaddr` sets where in the slave the data will be written. |
|
||||
@ -34,7 +34,6 @@ The following defines can be used to configure the I2C master driver.
|
||||
|Variable |Description |Default|
|
||||
|------------------|---------------------------------------------------|-------|
|
||||
|`F_SCL` |Clock frequency in Hz |400KHz |
|
||||
|`Prescaler` |Divides master clock to aid in I2C clock selection |1 |
|
||||
|
||||
AVRs usually have set GPIO which turn into I2C pins, therefore no further configuration is required.
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta property="og:title" content="QMK Firmware Docs">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:description" content="The full documenation of the open-source firmware">
|
||||
<meta property="og:description" content="The full documentation of the open-source firmware">
|
||||
<meta property="og:image" content="https://i.imgur.com/svjvIrw.jpg">
|
||||
<meta property="og:url" content="https://docs.qmk.fm">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
|
@ -261,6 +261,8 @@ This is a reference only. Each group of keys links to the page documenting their
|
||||
|----------------------------------|---------|------------------------------------|
|
||||
|`MAGIC_SWAP_CONTROL_CAPSLOCK` | |Swap Caps Lock and Left Control |
|
||||
|`MAGIC_CAPSLOCK_TO_CONTROL` | |Treat Caps Lock as Control |
|
||||
|`MAGIC_SWAP_LCTL_LGUI` | |Swap Left Control and GUI |
|
||||
|`MAGIC_SWAP_RCTL_RGUI` | |Swap Right Control and GUI |
|
||||
|`MAGIC_SWAP_LALT_LGUI` | |Swap Left Alt and GUI |
|
||||
|`MAGIC_SWAP_RALT_RGUI` | |Swap Right Alt and GUI |
|
||||
|`MAGIC_NO_GUI` | |Disable the GUI key |
|
||||
@ -268,8 +270,11 @@ This is a reference only. Each group of keys links to the page documenting their
|
||||
|`MAGIC_SWAP_BACKSLASH_BACKSPACE` | |Swap `\` and Backspace |
|
||||
|`MAGIC_HOST_NKRO` | |Force NKRO on |
|
||||
|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides |
|
||||
|`MAGIC_SWAP_CTL_GUI` |`CG_SWAP`|Swap Ctrl and GUI on both sides (for macOS)|
|
||||
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` | |Unswap Caps Lock and Left Control |
|
||||
|`MAGIC_UNCAPSLOCK_TO_CONTROL` | |Stop treating Caps Lock as Control |
|
||||
|`MAGIC_UNSWAP_LCTL_LGUI` | |Unswap Left Control and GUI |
|
||||
|`MAGIC_UNSWAP_RCTL_RGUI` | |Unswap Right Control and GUI |
|
||||
|`MAGIC_UNSWAP_LALT_LGUI` | |Unswap Left Alt and GUI |
|
||||
|`MAGIC_UNSWAP_RALT_RGUI` | |Unswap Right Alt and GUI |
|
||||
|`MAGIC_UNNO_GUI` | |Enable the GUI key |
|
||||
@ -277,8 +282,10 @@ This is a reference only. Each group of keys links to the page documenting their
|
||||
|`MAGIC_UNSWAP_BACKSLASH_BACKSPACE`| |Unswap `\` and Backspace |
|
||||
|`MAGIC_UNHOST_NKRO` | |Force NKRO off |
|
||||
|`MAGIC_UNSWAP_ALT_GUI` |`AG_NORM`|Unswap Alt and GUI on both sides |
|
||||
|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Alt and GUI swap on both sides|
|
||||
|`MAGIC_TOGGLE_NKRO` | |Turn NKRO on or off |
|
||||
|`MAGIC_UNSWAP_CTL_GUI` |`CG_NORM`|Unswap Ctrl and GUI on both sides |
|
||||
|`MAGIC_TOGGLE_ALT_GUI` |`AG_TOGG`|Toggle Alt and GUI swap on both sides |
|
||||
|`MAGIC_TOGGLE_CTL_GUI` |`CG_TOGG`|Toggle Ctrl and GUI swap on both sides |
|
||||
|`MAGIC_TOGGLE_NKRO` | |Turn NKRO on or off |
|
||||
|
||||
## [Bluetooth](feature_bluetooth.md)
|
||||
|
||||
|
@ -248,6 +248,42 @@ Programming.....................................................................
|
||||
Booting
|
||||
```
|
||||
|
||||
## BootloadHID
|
||||
|
||||
For Bootmapper Client(BMC)/bootloadHID/ATmega32A based boards, when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
|
||||
|
||||
make <my_keyboard>:<my_keymap>:bootloaderHID
|
||||
|
||||
For example, if your keymap is named "xyverz" and you're building a keymap for a jj40, you'll use this command:
|
||||
|
||||
make jj40:xyverz:bootloaderHID
|
||||
|
||||
Once the firmware finishes compiling, it will output something like this:
|
||||
|
||||
```
|
||||
Linking: .build/jj40_default.elf [OK]
|
||||
Creating load file for flashing: .build/jj40_default.hex [OK]
|
||||
Copying jj40_default.hex to qmk_firmware folder [OK]
|
||||
Checking file size of jj40_default.hex [OK]
|
||||
* The firmware size is fine - 21920/28672 (6752 bytes free)
|
||||
```
|
||||
|
||||
After it gets to this point, the build script will look for the DFU bootloader every 5 seconds. It will repeat the following until the device is found or you cancel it.
|
||||
|
||||
```
|
||||
Error opening HIDBoot device: The specified device was not found
|
||||
Trying again in 5s.
|
||||
```
|
||||
|
||||
Once it does this, you'll want to reset the controller. It should then show output similar to this:
|
||||
|
||||
```
|
||||
Page size = 128 (0x80)
|
||||
Device size = 32768 (0x8000); 30720 bytes remaining
|
||||
Uploading 22016 (0x5600) bytes starting at 0 (0x0)
|
||||
0x05580 ... 0x05600
|
||||
```
|
||||
|
||||
## STM32 (ARM)
|
||||
|
||||
For a majority of ARM boards (including the Proton C, Planck Rev 6, and Preonic Rev 3), when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
|
||||
|
@ -34,7 +34,7 @@ For the `DIODE_DIRECTION`, most hand-wiring guides will instruct you to wire the
|
||||
|
||||
To configure a keyboard where each switch is connected to a separate pin and ground instead of sharing row and column pins, use `DIRECT_PINS`. The mapping defines the pins of each switch in rows and columns, from left to right. Must conform to the sizes within `MATRIX_ROWS` and `MATRIX_COLS`, use `NO_PIN` to fill in blank spaces. Overrides the behaviour of `DIODE_DIRECTION`, `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`.
|
||||
|
||||
`BACKLIGHT_PIN` is the pin that your PWM-controlled backlight (if one exists) is hooked-up to. Currently only B5, B6, and B7 are supported.
|
||||
`BACKLIGHT_PIN` is the pin that your PWM-controlled backlight (if one exists) is hooked-up to.
|
||||
|
||||
`BACKLIGHT_BREATHING` is a fancier backlight feature that adds breathing/pulsing/fading effects to the backlight. It uses the same timer as the normal backlight. These breathing effects must be called by code in your keymap.
|
||||
|
||||
|
@ -50,7 +50,7 @@ The caveat to this method is that you cannot access the `z` layer without having
|
||||
#### Example
|
||||
|
||||
```c
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
```
|
||||
@ -58,7 +58,7 @@ uint32_t layer_state_set_user(uint32_t state) {
|
||||
Alternatively, you don't have to immediately "return" the value. This is useful if you want to add multiple tri layers, or if you want to add additional effects.
|
||||
|
||||
```c
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
||||
state = update_tri_layer_state(state, _RAISE, _SYMB, _SPECIAL);
|
||||
return state;
|
||||
|
@ -54,6 +54,7 @@
|
||||
* [热改键](feature_bootmagic.md)
|
||||
* [组合](feature_combo)
|
||||
* [命令](feature_command.md)
|
||||
* [拨动开关](feature_dip_switch.md)
|
||||
* [动态宏指令](feature_dynamic_macros.md)
|
||||
* [编码器](feature_encoders.md)
|
||||
* [重音号Esc复合键](feature_grave_esc.md)
|
||||
|
@ -173,23 +173,6 @@ EXTRAKEY_ENABLE = yes # 音频控制和系统控制
|
||||
|
||||
Arduino Leonardo和micro使用**ATMega32U4**,该芯片TMK可用,但Arduino的bootloader会导致问题。
|
||||
|
||||
|
||||
## 在USB AVR使用PF4-7针脚?
|
||||
你要置位MCUCR寄存器JTD位来将PF4-7设置为GPIO。这些针脚默认是JTAG功能。 像ATMega*U* or AT90USB*这样的MCU会受影响。
|
||||
|
||||
如果是用Teensy的话就不需要了。Tennsy自带JTAGEN位未编程来失能该功能。
|
||||
<!--翻译问题:上句可能有错,原文为:Teensy is shipped with JTAGEN fuse bit unprogrammed to disable the function. -->
|
||||
代码如下。
|
||||
```
|
||||
// F接口JTAG失能。在四个周期内写入两次JTD位。
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
```
|
||||
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hbkb/matrix.c#L67
|
||||
|
||||
阅读ATMega32U4的datasheet中的**26.5.1 MCU Control Register – MCUCR**。
|
||||
|
||||
|
||||
## 为锁定键添加指示灯
|
||||
你要自制CapsLock, ScrollLock 和 NumLock指示灯?见下文。
|
||||
|
||||
|
@ -34,98 +34,83 @@ static uint8_t i2c_address;
|
||||
|
||||
static const I2CConfig i2cconfig = {
|
||||
#ifdef USE_I2CV1
|
||||
I2C1_OPMODE,
|
||||
I2C1_CLOCK_SPEED,
|
||||
I2C1_DUTY_CYCLE,
|
||||
I2C1_OPMODE,
|
||||
I2C1_CLOCK_SPEED,
|
||||
I2C1_DUTY_CYCLE,
|
||||
#else
|
||||
STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) |
|
||||
STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) |
|
||||
STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL),
|
||||
0,
|
||||
0
|
||||
STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), 0, 0
|
||||
#endif
|
||||
};
|
||||
|
||||
static i2c_status_t chibios_to_qmk(const msg_t* status) {
|
||||
switch (*status) {
|
||||
case I2C_NO_ERROR:
|
||||
return I2C_STATUS_SUCCESS;
|
||||
case I2C_TIMEOUT:
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
// I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT
|
||||
default:
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
switch (*status) {
|
||||
case I2C_NO_ERROR:
|
||||
return I2C_STATUS_SUCCESS;
|
||||
case I2C_TIMEOUT:
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
// I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT
|
||||
default:
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void i2c_init(void)
|
||||
{
|
||||
// Try releasing special pins for a short time
|
||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
|
||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
|
||||
__attribute__((weak)) void i2c_init(void) {
|
||||
// Try releasing special pins for a short time
|
||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
|
||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
|
||||
|
||||
chThdSleepMilliseconds(10);
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
#ifdef USE_I2CV1
|
||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
|
||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
|
||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
|
||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
|
||||
#else
|
||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||
#endif
|
||||
|
||||
//i2cInit(); //This is invoked by halInit() so no need to redo it.
|
||||
// i2cInit(); //This is invoked by halInit() so no need to redo it.
|
||||
}
|
||||
|
||||
i2c_status_t i2c_start(uint8_t address)
|
||||
{
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
return I2C_STATUS_SUCCESS;
|
||||
i2c_status_t i2c_start(uint8_t address) {
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
return I2C_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
{
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
}
|
||||
|
||||
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
{
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
}
|
||||
|
||||
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
{
|
||||
i2c_address = devaddr;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_address = devaddr;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
|
||||
uint8_t complete_packet[length + 1];
|
||||
for(uint8_t i = 0; i < length; i++)
|
||||
{
|
||||
complete_packet[i+1] = data[i];
|
||||
}
|
||||
complete_packet[0] = regaddr;
|
||||
uint8_t complete_packet[length + 1];
|
||||
for (uint8_t i = 0; i < length; i++) {
|
||||
complete_packet[i + 1] = data[i];
|
||||
}
|
||||
complete_packet[0] = regaddr;
|
||||
|
||||
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
}
|
||||
|
||||
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
{
|
||||
i2c_address = devaddr;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), ®addr, 1, data, length, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_address = devaddr;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), ®addr, 1, data, length, MS2ST(timeout));
|
||||
return chibios_to_qmk(&status);
|
||||
}
|
||||
|
||||
void i2c_stop(void)
|
||||
{
|
||||
i2cStop(&I2C_DRIVER);
|
||||
}
|
||||
void i2c_stop(void) { i2cStop(&I2C_DRIVER); }
|
||||
|
@ -27,84 +27,83 @@
|
||||
#include "ch.h"
|
||||
#include <hal.h>
|
||||
|
||||
|
||||
#if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L0xx) || defined(STM32L1xx)
|
||||
#define USE_I2CV1
|
||||
# define USE_I2CV1
|
||||
#endif
|
||||
|
||||
#ifdef I2C1_BANK
|
||||
#define I2C1_SCL_BANK I2C1_BANK
|
||||
#define I2C1_SDA_BANK I2C1_BANK
|
||||
# define I2C1_SCL_BANK I2C1_BANK
|
||||
# define I2C1_SDA_BANK I2C1_BANK
|
||||
#endif
|
||||
|
||||
#ifndef I2C1_SCL_BANK
|
||||
#define I2C1_SCL_BANK GPIOB
|
||||
# define I2C1_SCL_BANK GPIOB
|
||||
#endif
|
||||
|
||||
#ifndef I2C1_SDA_BANK
|
||||
#define I2C1_SDA_BANK GPIOB
|
||||
# define I2C1_SDA_BANK GPIOB
|
||||
#endif
|
||||
|
||||
#ifndef I2C1_SCL
|
||||
#define I2C1_SCL 6
|
||||
# define I2C1_SCL 6
|
||||
#endif
|
||||
#ifndef I2C1_SDA
|
||||
#define I2C1_SDA 7
|
||||
# define I2C1_SDA 7
|
||||
#endif
|
||||
|
||||
#ifdef USE_I2CV1
|
||||
#ifndef I2C1_OPMODE
|
||||
#define I2C1_OPMODE OPMODE_I2C
|
||||
#endif
|
||||
#ifndef I2C1_CLOCK_SPEED
|
||||
#define I2C1_CLOCK_SPEED 100000 /* 400000 */
|
||||
#endif
|
||||
#ifndef I2C1_DUTY_CYCLE
|
||||
#define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */
|
||||
#endif
|
||||
# ifndef I2C1_OPMODE
|
||||
# define I2C1_OPMODE OPMODE_I2C
|
||||
# endif
|
||||
# ifndef I2C1_CLOCK_SPEED
|
||||
# define I2C1_CLOCK_SPEED 100000 /* 400000 */
|
||||
# endif
|
||||
# ifndef I2C1_DUTY_CYCLE
|
||||
# define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */
|
||||
# endif
|
||||
#else
|
||||
// The default PAL alternate modes are used to signal that the pins are used for I2C
|
||||
#ifndef I2C1_SCL_PAL_MODE
|
||||
#define I2C1_SCL_PAL_MODE 4
|
||||
#endif
|
||||
#ifndef I2C1_SDA_PAL_MODE
|
||||
#define I2C1_SDA_PAL_MODE 4
|
||||
#endif
|
||||
// The default PAL alternate modes are used to signal that the pins are used for I2C
|
||||
# ifndef I2C1_SCL_PAL_MODE
|
||||
# define I2C1_SCL_PAL_MODE 4
|
||||
# endif
|
||||
# ifndef I2C1_SDA_PAL_MODE
|
||||
# define I2C1_SDA_PAL_MODE 4
|
||||
# endif
|
||||
|
||||
// The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock
|
||||
// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
|
||||
#ifndef I2C1_TIMINGR_PRESC
|
||||
#define I2C1_TIMINGR_PRESC 15U
|
||||
#endif
|
||||
#ifndef I2C1_TIMINGR_SCLDEL
|
||||
#define I2C1_TIMINGR_SCLDEL 4U
|
||||
#endif
|
||||
#ifndef I2C1_TIMINGR_SDADEL
|
||||
#define I2C1_TIMINGR_SDADEL 2U
|
||||
#endif
|
||||
#ifndef I2C1_TIMINGR_SCLH
|
||||
#define I2C1_TIMINGR_SCLH 15U
|
||||
#endif
|
||||
#ifndef I2C1_TIMINGR_SCLL
|
||||
#define I2C1_TIMINGR_SCLL 21U
|
||||
#endif
|
||||
// The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock
|
||||
// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
|
||||
# ifndef I2C1_TIMINGR_PRESC
|
||||
# define I2C1_TIMINGR_PRESC 15U
|
||||
# endif
|
||||
# ifndef I2C1_TIMINGR_SCLDEL
|
||||
# define I2C1_TIMINGR_SCLDEL 4U
|
||||
# endif
|
||||
# ifndef I2C1_TIMINGR_SDADEL
|
||||
# define I2C1_TIMINGR_SDADEL 2U
|
||||
# endif
|
||||
# ifndef I2C1_TIMINGR_SCLH
|
||||
# define I2C1_TIMINGR_SCLH 15U
|
||||
# endif
|
||||
# ifndef I2C1_TIMINGR_SCLL
|
||||
# define I2C1_TIMINGR_SCLL 21U
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef I2C_DRIVER
|
||||
#define I2C_DRIVER I2CD1
|
||||
# define I2C_DRIVER I2CD1
|
||||
#endif
|
||||
|
||||
typedef int16_t i2c_status_t;
|
||||
|
||||
#define I2C_STATUS_SUCCESS (0)
|
||||
#define I2C_STATUS_ERROR (-1)
|
||||
#define I2C_STATUS_ERROR (-1)
|
||||
#define I2C_STATUS_TIMEOUT (-2)
|
||||
|
||||
void i2c_init(void);
|
||||
void i2c_init(void);
|
||||
i2c_status_t i2c_start(uint8_t address);
|
||||
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
|
||||
i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t* tx_body, uint16_t tx_length, uint8_t* rx_body, uint16_t rx_length);
|
||||
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
void i2c_stop(void);
|
||||
void i2c_stop(void);
|
||||
|
@ -21,49 +21,38 @@
|
||||
#include <stdint.h>
|
||||
#include "analog.h"
|
||||
|
||||
static uint8_t aref = (1 << REFS0); // default to AREF = Vcc
|
||||
|
||||
static uint8_t aref = (1<<REFS0); // default to AREF = Vcc
|
||||
|
||||
|
||||
void analogReference(uint8_t mode)
|
||||
{
|
||||
aref = mode & 0xC0;
|
||||
}
|
||||
|
||||
void analogReference(uint8_t mode) { aref = mode & 0xC0; }
|
||||
|
||||
// Arduino compatible pin input
|
||||
int16_t analogRead(uint8_t pin)
|
||||
{
|
||||
int16_t analogRead(uint8_t pin) {
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
static const uint8_t PROGMEM pin_to_mux[] = {
|
||||
0x00, 0x01, 0x04, 0x05, 0x06, 0x07,
|
||||
0x25, 0x24, 0x23, 0x22, 0x21, 0x20};
|
||||
if (pin >= 12) return 0;
|
||||
return adc_read(pgm_read_byte(pin_to_mux + pin));
|
||||
static const uint8_t PROGMEM pin_to_mux[] = {0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20};
|
||||
if (pin >= 12) return 0;
|
||||
return adc_read(pgm_read_byte(pin_to_mux + pin));
|
||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||
if (pin >= 8) return 0;
|
||||
return adc_read(pin);
|
||||
if (pin >= 8) return 0;
|
||||
return adc_read(pin);
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Mux input
|
||||
int16_t adc_read(uint8_t mux)
|
||||
{
|
||||
int16_t adc_read(uint8_t mux) {
|
||||
#if defined(__AVR_AT90USB162__)
|
||||
return 0;
|
||||
return 0;
|
||||
#else
|
||||
uint8_t low;
|
||||
uint8_t low;
|
||||
|
||||
ADCSRA = (1<<ADEN) | ADC_PRESCALER; // enable ADC
|
||||
ADCSRB = (1<<ADHSM) | (mux & 0x20); // high speed mode
|
||||
ADMUX = aref | (mux & 0x1F); // configure mux input
|
||||
ADCSRA = (1<<ADEN) | ADC_PRESCALER | (1<<ADSC); // start the conversion
|
||||
while (ADCSRA & (1<<ADSC)) ; // wait for result
|
||||
low = ADCL; // must read LSB first
|
||||
return (ADCH << 8) | low; // must read MSB only once!
|
||||
ADCSRA = (1 << ADEN) | ADC_PRESCALER; // enable ADC
|
||||
ADCSRB = (1 << ADHSM) | (mux & 0x20); // high speed mode
|
||||
ADMUX = aref | (mux & 0x1F); // configure mux input
|
||||
ADCSRA = (1 << ADEN) | ADC_PRESCALER | (1 << ADSC); // start the conversion
|
||||
while (ADCSRA & (1 << ADSC))
|
||||
; // wait for result
|
||||
low = ADCL; // must read LSB first
|
||||
return (ADCH << 8) | low; // must read MSB only once!
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,34 +19,40 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void analogReference(uint8_t mode);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void analogReference(uint8_t mode);
|
||||
int16_t analogRead(uint8_t pin);
|
||||
int16_t adc_read(uint8_t mux);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ADC_REF_POWER (1<<REFS0)
|
||||
#define ADC_REF_INTERNAL ((1<<REFS1) | (1<<REFS0))
|
||||
#define ADC_REF_EXTERNAL (0)
|
||||
#define ADC_REF_POWER (1 << REFS0)
|
||||
#define ADC_REF_INTERNAL ((1 << REFS1) | (1 << REFS0))
|
||||
#define ADC_REF_EXTERNAL (0)
|
||||
|
||||
// These prescaler values are for high speed mode, ADHSM = 1
|
||||
#if F_CPU == 16000000L
|
||||
#define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS1))
|
||||
# define ADC_PRESCALER ((1 << ADPS2) | (1 << ADPS1))
|
||||
#elif F_CPU == 8000000L
|
||||
#define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS0))
|
||||
# define ADC_PRESCALER ((1 << ADPS2) | (1 << ADPS0))
|
||||
#elif F_CPU == 4000000L
|
||||
#define ADC_PRESCALER ((1<<ADPS2))
|
||||
# define ADC_PRESCALER ((1 << ADPS2))
|
||||
#elif F_CPU == 2000000L
|
||||
#define ADC_PRESCALER ((1<<ADPS1) | (1<<ADPS0))
|
||||
# define ADC_PRESCALER ((1 << ADPS1) | (1 << ADPS0))
|
||||
#elif F_CPU == 1000000L
|
||||
#define ADC_PRESCALER ((1<<ADPS1))
|
||||
# define ADC_PRESCALER ((1 << ADPS1))
|
||||
#else
|
||||
#define ADC_PRESCALER ((1<<ADPS0))
|
||||
# define ADC_PRESCALER ((1 << ADPS0))
|
||||
#endif
|
||||
|
||||
// some avr-libc versions do not properly define ADHSM
|
||||
#if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||
#if !defined(ADHSM)
|
||||
#define ADHSM (7)
|
||||
#endif
|
||||
# if !defined(ADHSM)
|
||||
# define ADHSM (7)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
157
drivers/avr/apa102.c
Executable file → Normal file
157
drivers/avr/apa102.c
Executable file → Normal file
@ -1,24 +1,24 @@
|
||||
/*
|
||||
* APA102 lib V1.0a
|
||||
*
|
||||
* Controls APA102 RGB-LEDs
|
||||
* Author: Mikkel (Duckle29 on github)
|
||||
*
|
||||
* Dec 22th, 2017 v1.0a Initial Version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* APA102 lib V1.0a
|
||||
*
|
||||
* Controls APA102 RGB-LEDs
|
||||
* Author: Mikkel (Duckle29 on github)
|
||||
*
|
||||
* Dec 22th, 2017 v1.0a Initial Version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "apa102.h"
|
||||
#include <avr/interrupt.h>
|
||||
@ -27,75 +27,70 @@
|
||||
#include "debug.h"
|
||||
|
||||
// Setleds for standard RGB
|
||||
void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds){
|
||||
apa102_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF));
|
||||
void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds) { apa102_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF)); }
|
||||
|
||||
void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK) {
|
||||
pinMode(RGB_DI_PIN, PinDirectionOutput);
|
||||
pinMode(RGB_CLK_PIN, PinDirectionOutput);
|
||||
|
||||
apa102_send_array((uint8_t *)ledarray, leds)
|
||||
}
|
||||
|
||||
void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK){
|
||||
pinMode(RGB_DI_PIN, PinDirectionOutput);
|
||||
pinMode(RGB_CLK_PIN, PinDirectionOutput);
|
||||
|
||||
apa102_send_array((uint8_t*)ledarray,leds)
|
||||
void apa102_send_array(uint8_t *data, uint16_t leds) { // Data is struct of 3 bytes. RGB - leds is number of leds in data
|
||||
apa102_start_frame();
|
||||
while (leds--) {
|
||||
apa102_send_frame(0xFF000000 | (data->b << 16) | (data->g << 8) | data->r);
|
||||
data++;
|
||||
}
|
||||
apa102_end_frame(leds);
|
||||
}
|
||||
|
||||
void apa102_send_array(uint8_t *data, uint16_t leds){ // Data is struct of 3 bytes. RGB - leds is number of leds in data
|
||||
apa102_start_frame();
|
||||
while(leds--){
|
||||
apa102_send_frame(0xFF000000 | (data->b << 16) | (data->g << 8) | data->r);
|
||||
data++;
|
||||
}
|
||||
apa102_end_frame(leds);
|
||||
void apa102_send_frame(uint32_t frame) {
|
||||
for (uint32_t i = 0xFF; i > 0;) {
|
||||
apa102_send_byte(frame & i);
|
||||
i = i << 8;
|
||||
}
|
||||
}
|
||||
|
||||
void apa102_send_frame(uint32_t frame){
|
||||
for(uint32_t i=0xFF; i>0;){
|
||||
apa102_send_byte(frame & i);
|
||||
i = i << 8;
|
||||
}
|
||||
void apa102_start_frame() { apa102_send_frame(0); }
|
||||
|
||||
void apa102_end_frame(uint16_t leds) {
|
||||
// This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h
|
||||
// and adapted. The code is MIT licensed. I think thats compatible?
|
||||
|
||||
// We need to send some more bytes to ensure that all the LEDs in the
|
||||
// chain see their new color and start displaying it.
|
||||
//
|
||||
// The data stream seen by the last LED in the chain will be delayed by
|
||||
// (count - 1) clock edges, because each LED before it inverts the clock
|
||||
// line and delays the data by one clock edge. Therefore, to make sure
|
||||
// the last LED actually receives the data we wrote, the number of extra
|
||||
// edges we send at the end of the frame must be at least (count - 1).
|
||||
// For the APA102C, that is sufficient.
|
||||
//
|
||||
// The SK9822 only updates after it sees 32 zero bits followed by one more
|
||||
// rising edge. To avoid having the update time depend on the color of
|
||||
// the last LED, we send a dummy 0xFF byte. (Unfortunately, this means
|
||||
// that partial updates of the beginning of an LED strip are not possible;
|
||||
// the LED after the last one you are trying to update will be black.)
|
||||
// After that, to ensure that the last LED in the chain sees 32 zero bits
|
||||
// and a rising edge, we need to send at least 65 + (count - 1) edges. It
|
||||
// is sufficent and simpler to just send (5 + count/16) bytes of zeros.
|
||||
//
|
||||
// We are ignoring the specification for the end frame in the APA102/SK9822
|
||||
// datasheets because it does not actually ensure that all the LEDs will
|
||||
// start displaying their new colors right away.
|
||||
|
||||
apa102_send_byte(0xFF);
|
||||
for (uint16_t i = 0; i < 5 + leds / 16; i++) {
|
||||
apa102_send_byte(0);
|
||||
}
|
||||
}
|
||||
|
||||
void apa102_start_frame(){
|
||||
apa102_send_frame(0);
|
||||
}
|
||||
|
||||
void apa102_end_frame(uint16_t leds)
|
||||
{
|
||||
// This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h
|
||||
// and adapted. The code is MIT licensed. I think thats compatible?
|
||||
|
||||
// We need to send some more bytes to ensure that all the LEDs in the
|
||||
// chain see their new color and start displaying it.
|
||||
//
|
||||
// The data stream seen by the last LED in the chain will be delayed by
|
||||
// (count - 1) clock edges, because each LED before it inverts the clock
|
||||
// line and delays the data by one clock edge. Therefore, to make sure
|
||||
// the last LED actually receives the data we wrote, the number of extra
|
||||
// edges we send at the end of the frame must be at least (count - 1).
|
||||
// For the APA102C, that is sufficient.
|
||||
//
|
||||
// The SK9822 only updates after it sees 32 zero bits followed by one more
|
||||
// rising edge. To avoid having the update time depend on the color of
|
||||
// the last LED, we send a dummy 0xFF byte. (Unfortunately, this means
|
||||
// that partial updates of the beginning of an LED strip are not possible;
|
||||
// the LED after the last one you are trying to update will be black.)
|
||||
// After that, to ensure that the last LED in the chain sees 32 zero bits
|
||||
// and a rising edge, we need to send at least 65 + (count - 1) edges. It
|
||||
// is sufficent and simpler to just send (5 + count/16) bytes of zeros.
|
||||
//
|
||||
// We are ignoring the specification for the end frame in the APA102/SK9822
|
||||
// datasheets because it does not actually ensure that all the LEDs will
|
||||
// start displaying their new colors right away.
|
||||
|
||||
apa102_send_byte(0xFF);
|
||||
for (uint16_t i = 0; i < 5 + leds / 16; i++){
|
||||
apa102_send_byte(0);
|
||||
}
|
||||
}
|
||||
|
||||
void apa102_send_byte(uint8_t byte){
|
||||
uint8_t i;
|
||||
for (i = 0; i < 8; i++){
|
||||
void apa102_send_byte(uint8_t byte) {
|
||||
uint8_t i;
|
||||
for (i = 0; i < 8; i++) {
|
||||
digitalWrite(RGB_DI_PIN, !!(byte & (1 << (7-i)));
|
||||
digitalWrite(RGB_CLK_PIN, PinLevelHigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
drivers/avr/apa102.h
Executable file → Normal file
5
drivers/avr/apa102.h
Executable file → Normal file
@ -27,7 +27,6 @@
|
||||
|
||||
#include "color.h"
|
||||
|
||||
|
||||
/* User Interface
|
||||
*
|
||||
* Input:
|
||||
@ -41,6 +40,6 @@
|
||||
* - Wait 50<EFBFBD>s to reset the LEDs
|
||||
*/
|
||||
|
||||
void apa102_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
void apa102_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);
|
||||
void apa102_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
void apa102_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
|
||||
void apa102_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
|
@ -5,272 +5,30 @@
|
||||
#define FONT5X7_H
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
# include <avr/io.h>
|
||||
# include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <pgmspace.h>
|
||||
# include <pgmspace.h>
|
||||
#else
|
||||
#define PROGMEM
|
||||
# define PROGMEM
|
||||
#endif
|
||||
|
||||
// Standard ASCII 5x7 font
|
||||
|
||||
static const unsigned char font[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
|
||||
0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
|
||||
0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
|
||||
0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
|
||||
};
|
||||
#endif // FONT5X7_H
|
||||
#endif // FONT5X7_H
|
||||
|
@ -3,7 +3,7 @@
|
||||
Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury
|
||||
License: GNU General Public License Version 3
|
||||
File: $Id: lcd.c,v 1.15.2.2 2015/01/17 12:16:05 peter Exp $
|
||||
Software: AVR-GCC 3.3
|
||||
Software: AVR-GCC 3.3
|
||||
Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega
|
||||
|
||||
DESCRIPTION
|
||||
@ -13,15 +13,15 @@
|
||||
changed lcd_init(), added additional constants for lcd_command(),
|
||||
added 4-bit I/O mode, improved and optimized code.
|
||||
|
||||
Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
|
||||
Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
|
||||
4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported.
|
||||
|
||||
|
||||
Memory mapped mode compatible with Kanda STK200, but supports also
|
||||
generation of R/W signal through A8 address line.
|
||||
|
||||
USAGE
|
||||
See the C include lcd.h file for a description of each function
|
||||
|
||||
|
||||
*****************************************************************************/
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
@ -29,55 +29,54 @@
|
||||
#include <util/delay.h>
|
||||
#include "hd44780.h"
|
||||
|
||||
/*
|
||||
** constants/macros
|
||||
/*
|
||||
** constants/macros
|
||||
*/
|
||||
#define DDR(x) (*(&x - 1)) /* address of data direction register of port x */
|
||||
#define DDR(x) (*(&x - 1)) /* address of data direction register of port x */
|
||||
#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||
/* on ATmega64/128 PINF is on port 0x00 and not 0x60 */
|
||||
#define PIN(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) )
|
||||
/* on ATmega64/128 PINF is on port 0x00 and not 0x60 */
|
||||
# define PIN(x) (&PORTF == &(x) ? _SFR_IO8(0x00) : (*(&x - 2)))
|
||||
#else
|
||||
#define PIN(x) (*(&x - 2)) /* address of input register of port x */
|
||||
#endif
|
||||
|
||||
|
||||
#if LCD_IO_MODE
|
||||
#define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE)
|
||||
#define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN);
|
||||
#define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN);
|
||||
#define lcd_e_toggle() toggle_e()
|
||||
#define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN)
|
||||
#define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN)
|
||||
#define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN)
|
||||
#define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN)
|
||||
# define PIN(x) (*(&x - 2)) /* address of input register of port x */
|
||||
#endif
|
||||
|
||||
#if LCD_IO_MODE
|
||||
#if LCD_LINES==1
|
||||
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE
|
||||
#else
|
||||
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES
|
||||
# define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE)
|
||||
# define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN);
|
||||
# define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN);
|
||||
# define lcd_e_toggle() toggle_e()
|
||||
# define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN)
|
||||
# define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN)
|
||||
# define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN)
|
||||
# define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN)
|
||||
#endif
|
||||
|
||||
#if LCD_IO_MODE
|
||||
# if LCD_LINES == 1
|
||||
# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE
|
||||
# else
|
||||
# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES
|
||||
# endif
|
||||
#else
|
||||
#if LCD_LINES==1
|
||||
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE
|
||||
#else
|
||||
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES
|
||||
#endif
|
||||
# if LCD_LINES == 1
|
||||
# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE
|
||||
# else
|
||||
# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if LCD_CONTROLLER_KS0073
|
||||
#if LCD_LINES==4
|
||||
# if LCD_LINES == 4
|
||||
|
||||
#define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */
|
||||
#define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */
|
||||
#define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */
|
||||
# define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */
|
||||
# define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */
|
||||
# define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */
|
||||
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** function prototypes
|
||||
/*
|
||||
** function prototypes
|
||||
*/
|
||||
#if LCD_IO_MODE
|
||||
static void toggle_e(void);
|
||||
@ -87,93 +86,83 @@ static void toggle_e(void);
|
||||
** local functions
|
||||
*/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
/*************************************************************************
|
||||
delay for a minimum of <us> microseconds
|
||||
the number of loops is calculated at compile-time from MCU clock frequency
|
||||
*************************************************************************/
|
||||
#define delay(us) _delay_us(us)
|
||||
|
||||
#define delay(us) _delay_us(us)
|
||||
|
||||
#if LCD_IO_MODE
|
||||
/* toggle Enable Pin to initiate write */
|
||||
static void toggle_e(void)
|
||||
{
|
||||
static void toggle_e(void) {
|
||||
lcd_e_high();
|
||||
lcd_e_delay();
|
||||
lcd_e_low();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Low-level function to write byte to LCD controller
|
||||
Input: data byte to write to LCD
|
||||
rs 1: write data
|
||||
rs 1: write data
|
||||
0: write instruction
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
#if LCD_IO_MODE
|
||||
static void lcd_write(uint8_t data,uint8_t rs)
|
||||
{
|
||||
unsigned char dataBits ;
|
||||
static void lcd_write(uint8_t data, uint8_t rs) {
|
||||
unsigned char dataBits;
|
||||
|
||||
|
||||
if (rs) { /* write data (RS=1, RW=0) */
|
||||
lcd_rs_high();
|
||||
} else { /* write instruction (RS=0, RW=0) */
|
||||
lcd_rs_low();
|
||||
if (rs) { /* write data (RS=1, RW=0) */
|
||||
lcd_rs_high();
|
||||
} else { /* write instruction (RS=0, RW=0) */
|
||||
lcd_rs_low();
|
||||
}
|
||||
lcd_rw_low(); /* RW=0 write mode */
|
||||
lcd_rw_low(); /* RW=0 write mode */
|
||||
|
||||
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
|
||||
&& (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
|
||||
{
|
||||
if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) {
|
||||
/* configure data pins as output */
|
||||
DDR(LCD_DATA0_PORT) |= 0x0F;
|
||||
|
||||
/* output high nibble first */
|
||||
dataBits = LCD_DATA0_PORT & 0xF0;
|
||||
LCD_DATA0_PORT = dataBits |((data>>4)&0x0F);
|
||||
dataBits = LCD_DATA0_PORT & 0xF0;
|
||||
LCD_DATA0_PORT = dataBits | ((data >> 4) & 0x0F);
|
||||
lcd_e_toggle();
|
||||
|
||||
/* output low nibble */
|
||||
LCD_DATA0_PORT = dataBits | (data&0x0F);
|
||||
LCD_DATA0_PORT = dataBits | (data & 0x0F);
|
||||
lcd_e_toggle();
|
||||
|
||||
/* all data pins high (inactive) */
|
||||
LCD_DATA0_PORT = dataBits | 0x0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* configure data pins as output */
|
||||
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
|
||||
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
|
||||
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
|
||||
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
|
||||
|
||||
|
||||
/* output high nibble first */
|
||||
LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
|
||||
LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
|
||||
LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
|
||||
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
|
||||
if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
|
||||
if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
|
||||
if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
|
||||
if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
|
||||
if (data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
|
||||
if (data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
|
||||
if (data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
|
||||
if (data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
|
||||
lcd_e_toggle();
|
||||
|
||||
|
||||
/* output low nibble */
|
||||
LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
|
||||
LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
|
||||
LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
|
||||
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
|
||||
if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
|
||||
if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
|
||||
if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
|
||||
if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
|
||||
lcd_e_toggle();
|
||||
|
||||
if (data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
|
||||
if (data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
|
||||
if (data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
|
||||
if (data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
|
||||
lcd_e_toggle();
|
||||
|
||||
/* all data pins high (inactive) */
|
||||
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
|
||||
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
|
||||
@ -182,85 +171,81 @@ static void lcd_write(uint8_t data,uint8_t rs)
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d;
|
||||
# define lcd_write(d, rs) \
|
||||
if (rs) \
|
||||
*(volatile uint8_t *)(LCD_IO_DATA) = d; \
|
||||
else \
|
||||
*(volatile uint8_t *)(LCD_IO_FUNCTION) = d;
|
||||
/* rs==0 -> write instruction to LCD_IO_FUNCTION */
|
||||
/* rs==1 -> write data to LCD_IO_DATA */
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Low-level function to read byte from LCD controller
|
||||
Input: rs 1: read data
|
||||
Input: rs 1: read data
|
||||
0: read busy flag / address counter
|
||||
Returns: byte read from LCD controller
|
||||
*************************************************************************/
|
||||
#if LCD_IO_MODE
|
||||
static uint8_t lcd_read(uint8_t rs)
|
||||
{
|
||||
static uint8_t lcd_read(uint8_t rs) {
|
||||
uint8_t data;
|
||||
|
||||
|
||||
|
||||
if (rs)
|
||||
lcd_rs_high(); /* RS=1: read data */
|
||||
lcd_rs_high(); /* RS=1: read data */
|
||||
else
|
||||
lcd_rs_low(); /* RS=0: read busy flag */
|
||||
lcd_rw_high(); /* RW=1 read mode */
|
||||
|
||||
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
|
||||
&& ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
|
||||
{
|
||||
DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */
|
||||
|
||||
lcd_e_high();
|
||||
lcd_e_delay();
|
||||
data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */
|
||||
lcd_e_low();
|
||||
|
||||
lcd_e_delay(); /* Enable 500ns low */
|
||||
|
||||
lcd_rs_low(); /* RS=0: read busy flag */
|
||||
lcd_rw_high(); /* RW=1 read mode */
|
||||
|
||||
if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) {
|
||||
DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */
|
||||
|
||||
lcd_e_high();
|
||||
lcd_e_delay();
|
||||
data |= PIN(LCD_DATA0_PORT)&0x0F; /* read low nibble */
|
||||
data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */
|
||||
lcd_e_low();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
lcd_e_delay(); /* Enable 500ns low */
|
||||
|
||||
lcd_e_high();
|
||||
lcd_e_delay();
|
||||
data |= PIN(LCD_DATA0_PORT) & 0x0F; /* read low nibble */
|
||||
lcd_e_low();
|
||||
} else {
|
||||
/* configure data pins as input */
|
||||
DDR(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN);
|
||||
DDR(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN);
|
||||
DDR(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN);
|
||||
DDR(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN);
|
||||
|
||||
|
||||
/* read high nibble first */
|
||||
lcd_e_high();
|
||||
lcd_e_delay();
|
||||
lcd_e_delay();
|
||||
data = 0;
|
||||
if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x10;
|
||||
if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x20;
|
||||
if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x40;
|
||||
if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x80;
|
||||
if (PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN)) data |= 0x10;
|
||||
if (PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN)) data |= 0x20;
|
||||
if (PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN)) data |= 0x40;
|
||||
if (PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN)) data |= 0x80;
|
||||
lcd_e_low();
|
||||
|
||||
lcd_e_delay(); /* Enable 500ns low */
|
||||
|
||||
/* read low nibble */
|
||||
lcd_e_delay(); /* Enable 500ns low */
|
||||
|
||||
/* read low nibble */
|
||||
lcd_e_high();
|
||||
lcd_e_delay();
|
||||
if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x01;
|
||||
if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x02;
|
||||
if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x04;
|
||||
if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x08;
|
||||
if (PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN)) data |= 0x01;
|
||||
if (PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN)) data |= 0x02;
|
||||
if (PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN)) data |= 0x04;
|
||||
if (PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN)) data |= 0x08;
|
||||
lcd_e_low();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
#else
|
||||
#define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ)
|
||||
# define lcd_read(rs) (rs) ? *(volatile uint8_t *)(LCD_IO_DATA + LCD_IO_READ) : *(volatile uint8_t *)(LCD_IO_FUNCTION + LCD_IO_READ)
|
||||
/* rs==0 -> read instruction from LCD_IO_FUNCTION */
|
||||
/* rs==1 -> read data from LCD_IO_DATA */
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
loops while lcd is busy, returns address counter
|
||||
*************************************************************************/
|
||||
@ -268,65 +253,62 @@ static uint8_t lcd_waitbusy(void)
|
||||
|
||||
{
|
||||
register uint8_t c;
|
||||
|
||||
|
||||
/* wait until busy flag is cleared */
|
||||
while ( (c=lcd_read(0)) & (1<<LCD_BUSY)) {}
|
||||
|
||||
while ((c = lcd_read(0)) & (1 << LCD_BUSY)) {
|
||||
}
|
||||
|
||||
/* the address counter is updated 4us after the busy flag is cleared */
|
||||
delay(LCD_DELAY_BUSY_FLAG);
|
||||
|
||||
/* now read the address counter */
|
||||
return (lcd_read(0)); // return address counter
|
||||
|
||||
}/* lcd_waitbusy */
|
||||
|
||||
} /* lcd_waitbusy */
|
||||
|
||||
/*************************************************************************
|
||||
Move cursor to the start of next line or to the first line if the cursor
|
||||
Move cursor to the start of next line or to the first line if the cursor
|
||||
is already on the last line.
|
||||
*************************************************************************/
|
||||
static inline void lcd_newline(uint8_t pos)
|
||||
{
|
||||
static inline void lcd_newline(uint8_t pos) {
|
||||
register uint8_t addressCounter;
|
||||
|
||||
|
||||
#if LCD_LINES==1
|
||||
#if LCD_LINES == 1
|
||||
addressCounter = 0;
|
||||
#endif
|
||||
#if LCD_LINES==2
|
||||
if ( pos < (LCD_START_LINE2) )
|
||||
#if LCD_LINES == 2
|
||||
if (pos < (LCD_START_LINE2))
|
||||
addressCounter = LCD_START_LINE2;
|
||||
else
|
||||
addressCounter = LCD_START_LINE1;
|
||||
#endif
|
||||
#if LCD_LINES==4
|
||||
#if KS0073_4LINES_MODE
|
||||
if ( pos < LCD_START_LINE2 )
|
||||
#if LCD_LINES == 4
|
||||
# if KS0073_4LINES_MODE
|
||||
if (pos < LCD_START_LINE2)
|
||||
addressCounter = LCD_START_LINE2;
|
||||
else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3) )
|
||||
else if ((pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3))
|
||||
addressCounter = LCD_START_LINE3;
|
||||
else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4) )
|
||||
else if ((pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4))
|
||||
addressCounter = LCD_START_LINE4;
|
||||
else
|
||||
else
|
||||
addressCounter = LCD_START_LINE1;
|
||||
#else
|
||||
if ( pos < LCD_START_LINE3 )
|
||||
# else
|
||||
if (pos < LCD_START_LINE3)
|
||||
addressCounter = LCD_START_LINE2;
|
||||
else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4) )
|
||||
else if ((pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4))
|
||||
addressCounter = LCD_START_LINE3;
|
||||
else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2) )
|
||||
else if ((pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2))
|
||||
addressCounter = LCD_START_LINE4;
|
||||
else
|
||||
else
|
||||
addressCounter = LCD_START_LINE1;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
lcd_command((1<<LCD_DDRAM)+addressCounter);
|
||||
|
||||
}/* lcd_newline */
|
||||
lcd_command((1 << LCD_DDRAM) + addressCounter);
|
||||
|
||||
} /* lcd_newline */
|
||||
|
||||
/*
|
||||
** PUBLIC FUNCTIONS
|
||||
** PUBLIC FUNCTIONS
|
||||
*/
|
||||
|
||||
/*************************************************************************
|
||||
@ -334,132 +316,107 @@ Send LCD controller instruction command
|
||||
Input: instruction to send to LCD controller, see HD44780 data sheet
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
void lcd_command(uint8_t cmd)
|
||||
{
|
||||
void lcd_command(uint8_t cmd) {
|
||||
lcd_waitbusy();
|
||||
lcd_write(cmd,0);
|
||||
lcd_write(cmd, 0);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Send data byte to LCD controller
|
||||
Send data byte to LCD controller
|
||||
Input: data to send to LCD controller, see HD44780 data sheet
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
void lcd_data(uint8_t data)
|
||||
{
|
||||
void lcd_data(uint8_t data) {
|
||||
lcd_waitbusy();
|
||||
lcd_write(data,1);
|
||||
lcd_write(data, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Set cursor to specified position
|
||||
Input: x horizontal position (0: left most position)
|
||||
y vertical position (0: first line)
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
void lcd_gotoxy(uint8_t x, uint8_t y)
|
||||
{
|
||||
#if LCD_LINES==1
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
|
||||
void lcd_gotoxy(uint8_t x, uint8_t y) {
|
||||
#if LCD_LINES == 1
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x);
|
||||
#endif
|
||||
#if LCD_LINES==2
|
||||
if ( y==0 )
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
|
||||
#if LCD_LINES == 2
|
||||
if (y == 0)
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x);
|
||||
else
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE2 + x);
|
||||
#endif
|
||||
#if LCD_LINES==4
|
||||
if ( y==0 )
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
|
||||
else if ( y==1)
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
|
||||
else if ( y==2)
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE3+x);
|
||||
#if LCD_LINES == 4
|
||||
if (y == 0)
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x);
|
||||
else if (y == 1)
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE2 + x);
|
||||
else if (y == 2)
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE3 + x);
|
||||
else /* y==3 */
|
||||
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE4+x);
|
||||
lcd_command((1 << LCD_DDRAM) + LCD_START_LINE4 + x);
|
||||
#endif
|
||||
|
||||
}/* lcd_gotoxy */
|
||||
|
||||
} /* lcd_gotoxy */
|
||||
|
||||
/*************************************************************************
|
||||
*************************************************************************/
|
||||
int lcd_getxy(void)
|
||||
{
|
||||
return lcd_waitbusy();
|
||||
}
|
||||
|
||||
int lcd_getxy(void) { return lcd_waitbusy(); }
|
||||
|
||||
/*************************************************************************
|
||||
Clear display and set cursor to home position
|
||||
*************************************************************************/
|
||||
void lcd_clrscr(void)
|
||||
{
|
||||
lcd_command(1<<LCD_CLR);
|
||||
}
|
||||
|
||||
void lcd_clrscr(void) { lcd_command(1 << LCD_CLR); }
|
||||
|
||||
/*************************************************************************
|
||||
Set cursor to home position
|
||||
*************************************************************************/
|
||||
void lcd_home(void)
|
||||
{
|
||||
lcd_command(1<<LCD_HOME);
|
||||
}
|
||||
|
||||
void lcd_home(void) { lcd_command(1 << LCD_HOME); }
|
||||
|
||||
/*************************************************************************
|
||||
Display character at current cursor position
|
||||
Input: character to be displayed
|
||||
Display character at current cursor position
|
||||
Input: character to be displayed
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
void lcd_putc(char c)
|
||||
{
|
||||
void lcd_putc(char c) {
|
||||
uint8_t pos;
|
||||
|
||||
|
||||
pos = lcd_waitbusy(); // read busy-flag and address counter
|
||||
if (c=='\n')
|
||||
{
|
||||
pos = lcd_waitbusy(); // read busy-flag and address counter
|
||||
if (c == '\n') {
|
||||
lcd_newline(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if LCD_WRAP_LINES==1
|
||||
#if LCD_LINES==1
|
||||
if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
|
||||
} else {
|
||||
#if LCD_WRAP_LINES == 1
|
||||
# if LCD_LINES == 1
|
||||
if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0);
|
||||
}
|
||||
#elif LCD_LINES==2
|
||||
if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
|
||||
}else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ){
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
|
||||
# elif LCD_LINES == 2
|
||||
if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE2, 0);
|
||||
} else if (pos == LCD_START_LINE2 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0);
|
||||
}
|
||||
#elif LCD_LINES==4
|
||||
if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
|
||||
}else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ) {
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE3,0);
|
||||
}else if ( pos == LCD_START_LINE3+LCD_DISP_LENGTH ) {
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE4,0);
|
||||
}else if ( pos == LCD_START_LINE4+LCD_DISP_LENGTH ) {
|
||||
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
|
||||
# elif LCD_LINES == 4
|
||||
if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE2, 0);
|
||||
} else if (pos == LCD_START_LINE2 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE3, 0);
|
||||
} else if (pos == LCD_START_LINE3 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE4, 0);
|
||||
} else if (pos == LCD_START_LINE4 + LCD_DISP_LENGTH) {
|
||||
lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
lcd_waitbusy();
|
||||
#endif
|
||||
lcd_write(c, 1);
|
||||
}
|
||||
|
||||
}/* lcd_putc */
|
||||
|
||||
} /* lcd_putc */
|
||||
|
||||
/*************************************************************************
|
||||
Display string without auto linefeed
|
||||
Display string without auto linefeed
|
||||
Input: string to be displayed
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
@ -468,16 +425,15 @@ void lcd_puts(const char *s)
|
||||
{
|
||||
register char c;
|
||||
|
||||
while ( (c = *s++) ) {
|
||||
while ((c = *s++)) {
|
||||
lcd_putc(c);
|
||||
}
|
||||
|
||||
}/* lcd_puts */
|
||||
|
||||
} /* lcd_puts */
|
||||
|
||||
/*************************************************************************
|
||||
Display string from program memory without auto linefeed
|
||||
Input: string from program memory be be displayed
|
||||
Display string from program memory without auto linefeed
|
||||
Input: string from program memory be be displayed
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
void lcd_puts_p(const char *progmem_s)
|
||||
@ -485,108 +441,96 @@ void lcd_puts_p(const char *progmem_s)
|
||||
{
|
||||
register char c;
|
||||
|
||||
while ( (c = pgm_read_byte(progmem_s++)) ) {
|
||||
while ((c = pgm_read_byte(progmem_s++))) {
|
||||
lcd_putc(c);
|
||||
}
|
||||
|
||||
}/* lcd_puts_p */
|
||||
|
||||
} /* lcd_puts_p */
|
||||
|
||||
/*************************************************************************
|
||||
Initialize display and select type of cursor
|
||||
Initialize display and select type of cursor
|
||||
Input: dispAttr LCD_DISP_OFF display off
|
||||
LCD_DISP_ON display on, cursor off
|
||||
LCD_DISP_ON_CURSOR display on, cursor on
|
||||
LCD_DISP_CURSOR_BLINK display on, cursor on flashing
|
||||
Returns: none
|
||||
*************************************************************************/
|
||||
void lcd_init(uint8_t dispAttr)
|
||||
{
|
||||
void lcd_init(uint8_t dispAttr) {
|
||||
#if LCD_IO_MODE
|
||||
/*
|
||||
* Initialize LCD to 4 bit I/O mode
|
||||
*/
|
||||
|
||||
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
|
||||
&& ( &LCD_RS_PORT == &LCD_DATA0_PORT) && ( &LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT)
|
||||
&& (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)
|
||||
&& (LCD_RS_PIN == 4 ) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6 ) )
|
||||
{
|
||||
|
||||
if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (&LCD_RS_PORT == &LCD_DATA0_PORT) && (&LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) && (LCD_RS_PIN == 4) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6)) {
|
||||
/* configure all port bits as output (all LCD lines on same port) */
|
||||
DDR(LCD_DATA0_PORT) |= 0x7F;
|
||||
}
|
||||
else if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
|
||||
&& (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
|
||||
{
|
||||
} else if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) {
|
||||
/* configure all port bits as output (all LCD data lines on same port, but control lines on different ports) */
|
||||
DDR(LCD_DATA0_PORT) |= 0x0F;
|
||||
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
|
||||
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
|
||||
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
|
||||
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
|
||||
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
|
||||
} else {
|
||||
/* configure all port bits as output (LCD data and control lines on different ports */
|
||||
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
|
||||
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
|
||||
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
|
||||
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
|
||||
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
|
||||
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
|
||||
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
|
||||
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
|
||||
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
|
||||
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
|
||||
}
|
||||
delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */
|
||||
|
||||
delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */
|
||||
|
||||
/* initial write to lcd is 8bit */
|
||||
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4;
|
||||
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4;
|
||||
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4;
|
||||
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4;
|
||||
lcd_e_toggle();
|
||||
delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */
|
||||
|
||||
/* repeat last command */
|
||||
lcd_e_toggle();
|
||||
delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
|
||||
|
||||
delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */
|
||||
|
||||
/* repeat last command */
|
||||
lcd_e_toggle();
|
||||
delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
|
||||
|
||||
/* repeat last command a third time */
|
||||
lcd_e_toggle();
|
||||
delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
|
||||
lcd_e_toggle();
|
||||
delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
|
||||
|
||||
/* now configure for 4bit mode */
|
||||
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4
|
||||
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4
|
||||
lcd_e_toggle();
|
||||
delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */
|
||||
|
||||
/* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */
|
||||
delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */
|
||||
|
||||
/* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */
|
||||
#else
|
||||
/*
|
||||
* Initialize LCD to 8 bit memory mapped mode
|
||||
*/
|
||||
|
||||
/* enable external SRAM (memory mapped lcd) and one wait state */
|
||||
|
||||
/* enable external SRAM (memory mapped lcd) and one wait state */
|
||||
MCUCR = _BV(SRE) | _BV(SRW);
|
||||
|
||||
/* reset LCD */
|
||||
delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */
|
||||
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
|
||||
delay(LCD_DELAY_INIT); /* wait 5ms */
|
||||
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
|
||||
delay(LCD_DELAY_INIT_REP); /* wait 64us */
|
||||
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
|
||||
delay(LCD_DELAY_INIT_REP); /* wait 64us */
|
||||
delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */
|
||||
lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */
|
||||
delay(LCD_DELAY_INIT); /* wait 5ms */
|
||||
lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */
|
||||
delay(LCD_DELAY_INIT_REP); /* wait 64us */
|
||||
lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */
|
||||
delay(LCD_DELAY_INIT_REP); /* wait 64us */
|
||||
#endif
|
||||
|
||||
#if KS0073_4LINES_MODE
|
||||
/* Display with KS0073 controller requires special commands for enabling 4 line mode */
|
||||
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
|
||||
lcd_command(KS0073_4LINES_MODE);
|
||||
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
|
||||
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
|
||||
lcd_command(KS0073_4LINES_MODE);
|
||||
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
|
||||
#else
|
||||
lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
|
||||
lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
|
||||
#endif
|
||||
lcd_command(LCD_DISP_OFF); /* display off */
|
||||
lcd_clrscr(); /* display clear */
|
||||
lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
|
||||
lcd_command(dispAttr); /* display/cursor control */
|
||||
|
||||
}/* lcd_init */
|
||||
lcd_command(LCD_DISP_OFF); /* display off */
|
||||
lcd_clrscr(); /* display clear */
|
||||
lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
|
||||
lcd_command(dispAttr); /* display/cursor control */
|
||||
|
||||
} /* lcd_init */
|
||||
|
@ -6,7 +6,7 @@
|
||||
License: GNU General Public License Version 3
|
||||
File: $Id: lcd.h,v 1.14.2.4 2015/01/20 17:16:07 peter Exp $
|
||||
Software: AVR-GCC 4.x
|
||||
Hardware: any AVR device, memory mapped mode only for AVR with
|
||||
Hardware: any AVR device, memory mapped mode only for AVR with
|
||||
memory mapped interface (AT90S8515/ATmega8515/ATmega128)
|
||||
***************************************************************************/
|
||||
|
||||
@ -15,333 +15,315 @@
|
||||
Collection of libraries for AVR-GCC
|
||||
@author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury
|
||||
@copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
|
||||
|
||||
|
||||
@file
|
||||
@defgroup pfleury_lcd LCD library <lcd.h>
|
||||
@code #include <lcd.h> @endcode
|
||||
|
||||
|
||||
@brief Basic routines for interfacing a HD44780U-based character LCD display
|
||||
|
||||
LCD character displays can be found in many devices, like espresso machines, laser printers.
|
||||
The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays.
|
||||
|
||||
LCD character displays can be found in many devices, like espresso machines, laser printers.
|
||||
The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays.
|
||||
|
||||
This library allows easy interfacing with a HD44780 compatible display and can be
|
||||
operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in
|
||||
operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in
|
||||
4-bit IO port mode (LCD_IO_MODE defined as 1). 8-bit IO port mode is not supported.
|
||||
|
||||
Memory mapped mode is compatible with old Kanda STK200 starter kit, but also supports
|
||||
generation of R/W signal through A8 address line.
|
||||
|
||||
@see The chapter <a href=" http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" target="_blank">Interfacing a HD44780 Based LCD to an AVR</a>
|
||||
on my home page, which shows example circuits how to connect an LCD to an AVR controller.
|
||||
on my home page, which shows example circuits how to connect an LCD to an AVR controller.
|
||||
|
||||
@author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury
|
||||
|
||||
|
||||
@version 2.0
|
||||
|
||||
|
||||
@copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 405
|
||||
#error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
|
||||
# error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
|
||||
/*
|
||||
* LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file
|
||||
* LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file
|
||||
* by adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile
|
||||
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
|
||||
*/
|
||||
#ifdef _LCD_DEFINITIONS_FILE
|
||||
#include "lcd_definitions.h"
|
||||
# include "lcd_definitions.h"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @name Definition for LCD controller type
|
||||
* Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.
|
||||
*/
|
||||
#ifndef LCD_CONTROLLER_KS0073
|
||||
#define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
|
||||
#ifndef LCD_CONTROLLER_KS0073
|
||||
# define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Definitions for Display Size
|
||||
/**
|
||||
* @name Definitions for Display Size
|
||||
* Change these definitions to adapt setting to your display
|
||||
*
|
||||
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
|
||||
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
|
||||
* adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile.
|
||||
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
|
||||
*
|
||||
*/
|
||||
#ifndef LCD_LINES
|
||||
#define LCD_LINES 2 /**< number of visible lines of the display */
|
||||
# define LCD_LINES 2 /**< number of visible lines of the display */
|
||||
#endif
|
||||
#ifndef LCD_DISP_LENGTH
|
||||
#define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */
|
||||
# define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */
|
||||
#endif
|
||||
#ifndef LCD_LINE_LENGTH
|
||||
#define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */
|
||||
# define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */
|
||||
#endif
|
||||
#ifndef LCD_START_LINE1
|
||||
#define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */
|
||||
# define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */
|
||||
#endif
|
||||
#ifndef LCD_START_LINE2
|
||||
#define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */
|
||||
# define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */
|
||||
#endif
|
||||
#ifndef LCD_START_LINE3
|
||||
#define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */
|
||||
# define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */
|
||||
#endif
|
||||
#ifndef LCD_START_LINE4
|
||||
#define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */
|
||||
# define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */
|
||||
#endif
|
||||
#ifndef LCD_WRAP_LINES
|
||||
#define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */
|
||||
# define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @name Definitions for 4-bit IO mode
|
||||
*
|
||||
* The four LCD data lines and the three control lines RS, RW, E can be on the
|
||||
* same port or on different ports.
|
||||
* The four LCD data lines and the three control lines RS, RW, E can be on the
|
||||
* same port or on different ports.
|
||||
* Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on
|
||||
* different ports.
|
||||
* different ports.
|
||||
*
|
||||
* Normally the four data lines should be mapped to bit 0..3 on one port, but it
|
||||
* is possible to connect these data lines in different order or even on different
|
||||
* ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.
|
||||
*
|
||||
* Adjust these definitions to your target.\n
|
||||
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
|
||||
* Adjust these definitions to your target.\n
|
||||
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
|
||||
* adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile.
|
||||
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */
|
||||
#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */
|
||||
|
||||
#if LCD_IO_MODE
|
||||
|
||||
#ifndef LCD_PORT
|
||||
#define LCD_PORT PORTA /**< port for the LCD lines */
|
||||
#endif
|
||||
#ifndef LCD_DATA0_PORT
|
||||
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
|
||||
#endif
|
||||
#ifndef LCD_DATA1_PORT
|
||||
#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
|
||||
#endif
|
||||
#ifndef LCD_DATA2_PORT
|
||||
#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
|
||||
#endif
|
||||
#ifndef LCD_DATA3_PORT
|
||||
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
|
||||
#endif
|
||||
#ifndef LCD_DATA0_PIN
|
||||
#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */
|
||||
#endif
|
||||
#ifndef LCD_DATA1_PIN
|
||||
#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */
|
||||
#endif
|
||||
#ifndef LCD_DATA2_PIN
|
||||
#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */
|
||||
#endif
|
||||
#ifndef LCD_DATA3_PIN
|
||||
#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */
|
||||
#endif
|
||||
#ifndef LCD_RS_PORT
|
||||
#define LCD_RS_PORT LCD_PORT /**< port for RS line */
|
||||
#endif
|
||||
#ifndef LCD_RS_PIN
|
||||
#define LCD_RS_PIN 3 /**< pin for RS line */
|
||||
#endif
|
||||
#ifndef LCD_RW_PORT
|
||||
#define LCD_RW_PORT LCD_PORT /**< port for RW line */
|
||||
#endif
|
||||
#ifndef LCD_RW_PIN
|
||||
#define LCD_RW_PIN 2 /**< pin for RW line */
|
||||
#endif
|
||||
#ifndef LCD_E_PORT
|
||||
#define LCD_E_PORT LCD_PORT /**< port for Enable line */
|
||||
#endif
|
||||
#ifndef LCD_E_PIN
|
||||
#define LCD_E_PIN 1 /**< pin for Enable line */
|
||||
#endif
|
||||
# ifndef LCD_PORT
|
||||
# define LCD_PORT PORTA /**< port for the LCD lines */
|
||||
# endif
|
||||
# ifndef LCD_DATA0_PORT
|
||||
# define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
|
||||
# endif
|
||||
# ifndef LCD_DATA1_PORT
|
||||
# define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
|
||||
# endif
|
||||
# ifndef LCD_DATA2_PORT
|
||||
# define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
|
||||
# endif
|
||||
# ifndef LCD_DATA3_PORT
|
||||
# define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
|
||||
# endif
|
||||
# ifndef LCD_DATA0_PIN
|
||||
# define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */
|
||||
# endif
|
||||
# ifndef LCD_DATA1_PIN
|
||||
# define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */
|
||||
# endif
|
||||
# ifndef LCD_DATA2_PIN
|
||||
# define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */
|
||||
# endif
|
||||
# ifndef LCD_DATA3_PIN
|
||||
# define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */
|
||||
# endif
|
||||
# ifndef LCD_RS_PORT
|
||||
# define LCD_RS_PORT LCD_PORT /**< port for RS line */
|
||||
# endif
|
||||
# ifndef LCD_RS_PIN
|
||||
# define LCD_RS_PIN 3 /**< pin for RS line */
|
||||
# endif
|
||||
# ifndef LCD_RW_PORT
|
||||
# define LCD_RW_PORT LCD_PORT /**< port for RW line */
|
||||
# endif
|
||||
# ifndef LCD_RW_PIN
|
||||
# define LCD_RW_PIN 2 /**< pin for RW line */
|
||||
# endif
|
||||
# ifndef LCD_E_PORT
|
||||
# define LCD_E_PORT LCD_PORT /**< port for Enable line */
|
||||
# endif
|
||||
# ifndef LCD_E_PIN
|
||||
# define LCD_E_PIN 1 /**< pin for Enable line */
|
||||
# endif
|
||||
|
||||
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
|
||||
defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
|
||||
defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
|
||||
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || defined(__AVR_ATmega8515__) || defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
|
||||
/*
|
||||
* memory mapped mode is only supported when the device has an external data memory interface
|
||||
*/
|
||||
#define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */
|
||||
#define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */
|
||||
#define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */
|
||||
# define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */
|
||||
# define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */
|
||||
# define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */
|
||||
|
||||
#else
|
||||
#error "external data memory interface not available for this device, use 4-bit IO port mode"
|
||||
# error "external data memory interface not available for this device, use 4-bit IO port mode"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @name Definitions of delays
|
||||
* Used to calculate delay timers.
|
||||
* Adapt the F_CPU define in the Makefile to the clock frequency in Hz of your target
|
||||
*
|
||||
* These delay times can be adjusted, if some displays require different delays.\n
|
||||
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
|
||||
* These delay times can be adjusted, if some displays require different delays.\n
|
||||
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
|
||||
* adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile.
|
||||
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
|
||||
*/
|
||||
#ifndef LCD_DELAY_BOOTUP
|
||||
#define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */
|
||||
# define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */
|
||||
#endif
|
||||
#ifndef LCD_DELAY_INIT
|
||||
#define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */
|
||||
# define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */
|
||||
#endif
|
||||
#ifndef LCD_DELAY_INIT_REP
|
||||
#define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */
|
||||
# define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */
|
||||
#endif
|
||||
#ifndef LCD_DELAY_INIT_4BIT
|
||||
#define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */
|
||||
# define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */
|
||||
#endif
|
||||
#ifndef LCD_DELAY_BUSY_FLAG
|
||||
#define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */
|
||||
# define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */
|
||||
#endif
|
||||
#ifndef LCD_DELAY_ENABLE_PULSE
|
||||
#define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */
|
||||
# define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @name Definitions for LCD command instructions
|
||||
* The constants define the various LCD controller instructions which can be passed to the
|
||||
* The constants define the various LCD controller instructions which can be passed to the
|
||||
* function lcd_command(), see HD44780 data sheet for a complete description.
|
||||
*/
|
||||
|
||||
/* instruction register bit positions, see HD44780U data sheet */
|
||||
#define LCD_CLR 0 /* DB0: clear display */
|
||||
#define LCD_HOME 1 /* DB1: return to home position */
|
||||
#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */
|
||||
#define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */
|
||||
#define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */
|
||||
#define LCD_ON 3 /* DB3: turn lcd/cursor on */
|
||||
#define LCD_ON_DISPLAY 2 /* DB2: turn display on */
|
||||
#define LCD_ON_CURSOR 1 /* DB1: turn cursor on */
|
||||
#define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */
|
||||
#define LCD_MOVE 4 /* DB4: move cursor/display */
|
||||
#define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */
|
||||
#define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */
|
||||
#define LCD_FUNCTION 5 /* DB5: function set */
|
||||
#define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */
|
||||
#define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */
|
||||
#define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */
|
||||
#define LCD_CGRAM 6 /* DB6: set CG RAM address */
|
||||
#define LCD_DDRAM 7 /* DB7: set DD RAM address */
|
||||
#define LCD_BUSY 7 /* DB7: LCD is busy */
|
||||
#define LCD_CLR 0 /* DB0: clear display */
|
||||
#define LCD_HOME 1 /* DB1: return to home position */
|
||||
#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */
|
||||
#define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */
|
||||
#define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */
|
||||
#define LCD_ON 3 /* DB3: turn lcd/cursor on */
|
||||
#define LCD_ON_DISPLAY 2 /* DB2: turn display on */
|
||||
#define LCD_ON_CURSOR 1 /* DB1: turn cursor on */
|
||||
#define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */
|
||||
#define LCD_MOVE 4 /* DB4: move cursor/display */
|
||||
#define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */
|
||||
#define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */
|
||||
#define LCD_FUNCTION 5 /* DB5: function set */
|
||||
#define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */
|
||||
#define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */
|
||||
#define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */
|
||||
#define LCD_CGRAM 6 /* DB6: set CG RAM address */
|
||||
#define LCD_DDRAM 7 /* DB7: set DD RAM address */
|
||||
#define LCD_BUSY 7 /* DB7: LCD is busy */
|
||||
|
||||
/* set entry mode: display shift on/off, dec/inc cursor move direction */
|
||||
#define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */
|
||||
#define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */
|
||||
#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */
|
||||
#define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */
|
||||
#define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */
|
||||
#define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */
|
||||
#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */
|
||||
#define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */
|
||||
|
||||
/* display on/off, cursor on/off, blinking char at cursor position */
|
||||
#define LCD_DISP_OFF 0x08 /* display off */
|
||||
#define LCD_DISP_ON 0x0C /* display on, cursor off */
|
||||
#define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */
|
||||
#define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */
|
||||
#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */
|
||||
#define LCD_DISP_OFF 0x08 /* display off */
|
||||
#define LCD_DISP_ON 0x0C /* display on, cursor off */
|
||||
#define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */
|
||||
#define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */
|
||||
#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */
|
||||
|
||||
/* move cursor/shift display */
|
||||
#define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */
|
||||
#define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */
|
||||
#define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */
|
||||
#define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */
|
||||
#define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */
|
||||
#define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */
|
||||
#define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */
|
||||
#define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */
|
||||
|
||||
/* function set: set interface data length and number of display lines */
|
||||
#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */
|
||||
#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */
|
||||
#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */
|
||||
#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */
|
||||
#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */
|
||||
#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */
|
||||
#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */
|
||||
#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */
|
||||
|
||||
#define LCD_MODE_DEFAULT ((1 << LCD_ENTRY_MODE) | (1 << LCD_ENTRY_INC))
|
||||
|
||||
#define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @name Functions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@brief Initialize display and select type of cursor
|
||||
@param dispAttr \b LCD_DISP_OFF display off\n
|
||||
\b LCD_DISP_ON display on, cursor off\n
|
||||
\b LCD_DISP_ON_CURSOR display on, cursor on\n
|
||||
\b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
|
||||
\b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_init(uint8_t dispAttr);
|
||||
|
||||
|
||||
/**
|
||||
@brief Clear display and set cursor to home position
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_clrscr(void);
|
||||
|
||||
|
||||
/**
|
||||
@brief Set cursor to home position
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_home(void);
|
||||
|
||||
|
||||
/**
|
||||
@brief Set cursor to specified position
|
||||
|
||||
|
||||
@param x horizontal position\n (0: left most position)
|
||||
@param y vertical position\n (0: first line)
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_gotoxy(uint8_t x, uint8_t y);
|
||||
|
||||
|
||||
/**
|
||||
@brief Display character at current cursor position
|
||||
@param c character to be displayed
|
||||
@param c character to be displayed
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_putc(char c);
|
||||
|
||||
|
||||
/**
|
||||
@brief Display string without auto linefeed
|
||||
@param s string to be displayed
|
||||
@param s string to be displayed
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_puts(const char *s);
|
||||
|
||||
|
||||
/**
|
||||
@brief Display string from program memory without auto linefeed
|
||||
@param progmem_s string from program memory be be displayed
|
||||
@param progmem_s string from program memory be be displayed
|
||||
@return none
|
||||
@see lcd_puts_P
|
||||
*/
|
||||
extern void lcd_puts_p(const char *progmem_s);
|
||||
|
||||
|
||||
/**
|
||||
@brief Send LCD controller instruction command
|
||||
@param cmd instruction to send to LCD controller, see HD44780 data sheet
|
||||
@ -349,23 +331,20 @@ extern void lcd_puts_p(const char *progmem_s);
|
||||
*/
|
||||
extern void lcd_command(uint8_t cmd);
|
||||
|
||||
|
||||
/**
|
||||
@brief Send data byte to LCD controller
|
||||
|
||||
@brief Send data byte to LCD controller
|
||||
|
||||
Similar to lcd_putc(), but without interpreting LF
|
||||
@param data byte to send to LCD controller, see HD44780 data sheet
|
||||
@return none
|
||||
*/
|
||||
extern void lcd_data(uint8_t data);
|
||||
|
||||
|
||||
/**
|
||||
@brief macros for automatically storing string constant in program memory
|
||||
*/
|
||||
#define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
|
||||
#define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif //LCD_H
|
||||
|
||||
#endif // LCD_H
|
||||
|
254
drivers/avr/i2c_master.c
Executable file → Normal file
254
drivers/avr/i2c_master.c
Executable file → Normal file
@ -25,200 +25,200 @@
|
||||
#include "wait.h"
|
||||
|
||||
#ifndef F_SCL
|
||||
# define F_SCL 400000UL // SCL frequency
|
||||
# define F_SCL 400000UL // SCL frequency
|
||||
#endif
|
||||
#define Prescaler 1
|
||||
#define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16) / 2)
|
||||
|
||||
#define TWBR_val (((F_CPU / F_SCL) - 16) / 2)
|
||||
|
||||
void i2c_init(void) {
|
||||
TWSR = 0; /* no prescaler */
|
||||
TWBR = (uint8_t)TWBR_val;
|
||||
TWSR = 0; /* no prescaler */
|
||||
TWBR = (uint8_t)TWBR_val;
|
||||
|
||||
#ifdef __AVR_ATmega32A__
|
||||
// set pull-up resistors on I2C bus pins
|
||||
PORTC |= 0b11;
|
||||
#ifdef __AVR_ATmega32A__
|
||||
// set pull-up resistors on I2C bus pins
|
||||
PORTC |= 0b11;
|
||||
|
||||
// enable TWI (two-wire interface)
|
||||
TWCR |= (1 << TWEN);
|
||||
// enable TWI (two-wire interface)
|
||||
TWCR |= (1 << TWEN);
|
||||
|
||||
// enable TWI interrupt and slave address ACK
|
||||
TWCR |= (1 << TWIE);
|
||||
TWCR |= (1 << TWEA);
|
||||
#endif
|
||||
// enable TWI interrupt and slave address ACK
|
||||
TWCR |= (1 << TWIE);
|
||||
TWCR |= (1 << TWEA);
|
||||
#endif
|
||||
}
|
||||
|
||||
i2c_status_t i2c_start(uint8_t address, uint16_t timeout) {
|
||||
// reset TWI control register
|
||||
TWCR = 0;
|
||||
// transmit START condition
|
||||
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
|
||||
// reset TWI control register
|
||||
TWCR = 0;
|
||||
// transmit START condition
|
||||
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
|
||||
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the start condition was successfully transmitted
|
||||
if (((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)) {
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
|
||||
// load slave address into data register
|
||||
TWDR = address;
|
||||
// start transmission of address
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
|
||||
timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
// check if the start condition was successfully transmitted
|
||||
if (((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)) {
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the device has acknowledged the READ / WRITE mode
|
||||
uint8_t twst = TW_STATUS & 0xF8;
|
||||
if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
// load slave address into data register
|
||||
TWDR = address;
|
||||
// start transmission of address
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
|
||||
return I2C_STATUS_SUCCESS;
|
||||
timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the device has acknowledged the READ / WRITE mode
|
||||
uint8_t twst = TW_STATUS & 0xF8;
|
||||
if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return I2C_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
i2c_status_t i2c_write(uint8_t data, uint16_t timeout) {
|
||||
// load data into data register
|
||||
TWDR = data;
|
||||
// start transmission of data
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
// load data into data register
|
||||
TWDR = data;
|
||||
// start transmission of data
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((TW_STATUS & 0xF8) != TW_MT_DATA_ACK) {
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
if ((TW_STATUS & 0xF8) != TW_MT_DATA_ACK) {
|
||||
return I2C_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return I2C_STATUS_SUCCESS;
|
||||
return I2C_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int16_t i2c_read_ack(uint16_t timeout) {
|
||||
// start TWI module and acknowledge data after reception
|
||||
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
|
||||
// start TWI module and acknowledge data after reception
|
||||
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
|
||||
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return received data from TWDR
|
||||
return TWDR;
|
||||
// return received data from TWDR
|
||||
return TWDR;
|
||||
}
|
||||
|
||||
int16_t i2c_read_nack(uint16_t timeout) {
|
||||
// start receiving without acknowledging reception
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
// start receiving without acknowledging reception
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
uint16_t timeout_timer = timer_read();
|
||||
while (!(TWCR & (1 << TWINT))) {
|
||||
if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
|
||||
return I2C_STATUS_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return received data from TWDR
|
||||
return TWDR;
|
||||
// return received data from TWDR
|
||||
return TWDR;
|
||||
}
|
||||
|
||||
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
|
||||
i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
|
||||
|
||||
for (uint16_t i = 0; i < length && status >= 0; i++) {
|
||||
status = i2c_write(data[i], timeout);
|
||||
}
|
||||
for (uint16_t i = 0; i < length && status >= 0; i++) {
|
||||
status = i2c_write(data[i], timeout);
|
||||
}
|
||||
|
||||
i2c_stop();
|
||||
i2c_stop();
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_status_t status = i2c_start(address | I2C_READ, timeout);
|
||||
i2c_status_t status = i2c_start(address | I2C_READ, timeout);
|
||||
|
||||
for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
|
||||
status = i2c_read_ack(timeout);
|
||||
if (status >= 0) {
|
||||
data[i] = status;
|
||||
for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
|
||||
status = i2c_read_ack(timeout);
|
||||
if (status >= 0) {
|
||||
data[i] = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status >= 0) {
|
||||
status = i2c_read_nack(timeout);
|
||||
if (status >= 0) {
|
||||
data[(length - 1)] = status;
|
||||
status = i2c_read_nack(timeout);
|
||||
if (status >= 0) {
|
||||
data[(length - 1)] = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i2c_stop();
|
||||
i2c_stop();
|
||||
|
||||
return (status < 0) ? status : I2C_STATUS_SUCCESS;
|
||||
return (status < 0) ? status : I2C_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_status_t status = i2c_start(devaddr | 0x00, timeout);
|
||||
if (status >= 0) {
|
||||
status = i2c_write(regaddr, timeout);
|
||||
i2c_status_t status = i2c_start(devaddr | 0x00, timeout);
|
||||
if (status >= 0) {
|
||||
status = i2c_write(regaddr, timeout);
|
||||
|
||||
for (uint16_t i = 0; i < length && status >= 0; i++) {
|
||||
status = i2c_write(data[i], timeout);
|
||||
for (uint16_t i = 0; i < length && status >= 0; i++) {
|
||||
status = i2c_write(data[i], timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i2c_stop();
|
||||
i2c_stop();
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_status_t status = i2c_start(devaddr, timeout);
|
||||
if (status < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = i2c_write(regaddr, timeout);
|
||||
if (status < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = i2c_start(devaddr | 0x01, timeout);
|
||||
|
||||
for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
|
||||
status = i2c_read_ack(timeout);
|
||||
if (status >= 0) {
|
||||
data[i] = status;
|
||||
i2c_status_t status = i2c_start(devaddr, timeout);
|
||||
if (status < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (status >= 0) {
|
||||
status = i2c_read_nack(timeout);
|
||||
if (status >= 0) {
|
||||
data[(length - 1)] = status;
|
||||
status = i2c_write(regaddr, timeout);
|
||||
if (status < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = i2c_start(devaddr | 0x01, timeout);
|
||||
|
||||
for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
|
||||
status = i2c_read_ack(timeout);
|
||||
if (status >= 0) {
|
||||
data[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
if (status >= 0) {
|
||||
status = i2c_read_nack(timeout);
|
||||
if (status >= 0) {
|
||||
data[(length - 1)] = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
i2c_stop();
|
||||
i2c_stop();
|
||||
|
||||
return (status < 0) ? status : I2C_STATUS_SUCCESS;
|
||||
return (status < 0) ? status : I2C_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void i2c_stop(void) {
|
||||
// transmit STOP condition
|
||||
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
|
||||
// transmit STOP condition
|
||||
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
|
||||
}
|
||||
|
12
drivers/avr/i2c_master.h
Executable file → Normal file
12
drivers/avr/i2c_master.h
Executable file → Normal file
@ -26,21 +26,21 @@
|
||||
typedef int16_t i2c_status_t;
|
||||
|
||||
#define I2C_STATUS_SUCCESS (0)
|
||||
#define I2C_STATUS_ERROR (-1)
|
||||
#define I2C_STATUS_ERROR (-1)
|
||||
#define I2C_STATUS_TIMEOUT (-2)
|
||||
|
||||
#define I2C_TIMEOUT_IMMEDIATE (0)
|
||||
#define I2C_TIMEOUT_INFINITE (0xFFFF)
|
||||
|
||||
void i2c_init(void);
|
||||
void i2c_init(void);
|
||||
i2c_status_t i2c_start(uint8_t address, uint16_t timeout);
|
||||
i2c_status_t i2c_write(uint8_t data, uint16_t timeout);
|
||||
int16_t i2c_read_ack(uint16_t timeout);
|
||||
int16_t i2c_read_nack(uint16_t timeout);
|
||||
int16_t i2c_read_ack(uint16_t timeout);
|
||||
int16_t i2c_read_nack(uint16_t timeout);
|
||||
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
void i2c_stop(void);
|
||||
void i2c_stop(void);
|
||||
|
||||
#endif // I2C_MASTER_H
|
||||
#endif // I2C_MASTER_H
|
||||
|
18
drivers/avr/i2c_slave.c
Executable file → Normal file
18
drivers/avr/i2c_slave.c
Executable file → Normal file
@ -27,24 +27,24 @@
|
||||
volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT];
|
||||
|
||||
static volatile uint8_t buffer_address;
|
||||
static volatile bool slave_has_register_set = false;
|
||||
static volatile bool slave_has_register_set = false;
|
||||
|
||||
void i2c_slave_init(uint8_t address){
|
||||
void i2c_slave_init(uint8_t address) {
|
||||
// load address into TWI address register
|
||||
TWAR = address;
|
||||
// set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt
|
||||
TWCR = (1 << TWIE) | (1 << TWEA) | (1 << TWINT) | (1 << TWEN);
|
||||
}
|
||||
|
||||
void i2c_slave_stop(void){
|
||||
void i2c_slave_stop(void) {
|
||||
// clear acknowledge and enable bits
|
||||
TWCR &= ~((1 << TWEA) | (1 << TWEN));
|
||||
}
|
||||
|
||||
ISR(TWI_vect){
|
||||
ISR(TWI_vect) {
|
||||
uint8_t ack = 1;
|
||||
|
||||
switch(TW_STATUS){
|
||||
switch (TW_STATUS) {
|
||||
case TW_SR_SLA_ACK:
|
||||
// The device is now a slave receiver
|
||||
slave_has_register_set = false;
|
||||
@ -53,14 +53,14 @@ ISR(TWI_vect){
|
||||
case TW_SR_DATA_ACK:
|
||||
// This device is a slave receiver and has received data
|
||||
// First byte is the location then the bytes will be writen in buffer with auto-incriment
|
||||
if(!slave_has_register_set){
|
||||
if (!slave_has_register_set) {
|
||||
buffer_address = TWDR;
|
||||
|
||||
if (buffer_address >= I2C_SLAVE_REG_COUNT) { // address out of bounds dont ack
|
||||
ack = 0;
|
||||
buffer_address = 0;
|
||||
ack = 0;
|
||||
buffer_address = 0;
|
||||
}
|
||||
slave_has_register_set = true; // address has been receaved now fill in buffer
|
||||
slave_has_register_set = true; // address has been receaved now fill in buffer
|
||||
} else {
|
||||
i2c_slave_reg[buffer_address] = TWDR;
|
||||
buffer_address++;
|
||||
|
2
drivers/avr/i2c_slave.h
Executable file → Normal file
2
drivers/avr/i2c_slave.h
Executable file → Normal file
@ -30,4 +30,4 @@ extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT];
|
||||
void i2c_slave_init(uint8_t address);
|
||||
void i2c_slave_stop(void);
|
||||
|
||||
#endif // I2C_SLAVE_H
|
||||
#endif // I2C_SLAVE_H
|
||||
|
@ -90,14 +90,14 @@
|
||||
#undef OCR2_6
|
||||
#undef OCR2_7
|
||||
|
||||
#define NUM_DIGITAL_PINS 30
|
||||
#define NUM_DIGITAL_PINS 30
|
||||
#define NUM_ANALOG_INPUTS 12
|
||||
|
||||
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
|
||||
#define TXLED0 PORTD |= (1<<5)
|
||||
#define TXLED1 PORTD &= ~(1<<5)
|
||||
#define RXLED0 PORTB |= (1<<0)
|
||||
#define RXLED1 PORTB &= ~(1<<0)
|
||||
#define TX_RX_LED_INIT DDRD |= (1 << 5), DDRB |= (1 << 0)
|
||||
#define TXLED0 PORTD |= (1 << 5)
|
||||
#define TXLED1 PORTD &= ~(1 << 5)
|
||||
#define RXLED0 PORTB |= (1 << 0)
|
||||
#define RXLED1 PORTB &= ~(1 << 0)
|
||||
|
||||
static const uint8_t SDA = 2;
|
||||
static const uint8_t SCL = 3;
|
||||
@ -111,27 +111,27 @@ static const uint8_t SCK = 15;
|
||||
|
||||
// Mapping of analog pins as digital I/O
|
||||
// A6-A11 share with digital pins
|
||||
static const uint8_t ADC0 = 18;
|
||||
static const uint8_t ADC1 = 19;
|
||||
static const uint8_t ADC2 = 20;
|
||||
static const uint8_t ADC3 = 21;
|
||||
static const uint8_t ADC4 = 22;
|
||||
static const uint8_t ADC5 = 23;
|
||||
static const uint8_t ADC6 = 24; // D4
|
||||
static const uint8_t ADC7 = 25; // D6
|
||||
static const uint8_t ADC8 = 26; // D8
|
||||
static const uint8_t ADC9 = 27; // D9
|
||||
static const uint8_t ADC0 = 18;
|
||||
static const uint8_t ADC1 = 19;
|
||||
static const uint8_t ADC2 = 20;
|
||||
static const uint8_t ADC3 = 21;
|
||||
static const uint8_t ADC4 = 22;
|
||||
static const uint8_t ADC5 = 23;
|
||||
static const uint8_t ADC6 = 24; // D4
|
||||
static const uint8_t ADC7 = 25; // D6
|
||||
static const uint8_t ADC8 = 26; // D8
|
||||
static const uint8_t ADC9 = 27; // D9
|
||||
static const uint8_t ADC10 = 28; // D10
|
||||
static const uint8_t ADC11 = 29; // D12
|
||||
|
||||
#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
|
||||
#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
|
||||
#define digitalPinToPCICRbit(p) 0
|
||||
#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
|
||||
#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
|
||||
#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
|
||||
#define digitalPinToPCMSKbit(p) (((p) >= 8 && (p) <= 11) ? (p)-4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
|
||||
|
||||
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
|
||||
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
|
||||
#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
|
||||
#define analogPinToChannel(P) (pgm_read_byte(analog_pin_to_channel_PGM + (P)))
|
||||
|
||||
#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
|
||||
|
||||
@ -182,159 +182,121 @@ extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
|
||||
// appropriate addresses for various functions (e.g. reading
|
||||
// and writing)
|
||||
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &DDRB,
|
||||
(uint16_t) &DDRC,
|
||||
(uint16_t) &DDRD,
|
||||
(uint16_t) &DDRE,
|
||||
(uint16_t) &DDRF,
|
||||
NOT_A_PORT, NOT_A_PORT, (uint16_t)&DDRB, (uint16_t)&DDRC, (uint16_t)&DDRD, (uint16_t)&DDRE, (uint16_t)&DDRF,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PORTB,
|
||||
(uint16_t) &PORTC,
|
||||
(uint16_t) &PORTD,
|
||||
(uint16_t) &PORTE,
|
||||
(uint16_t) &PORTF,
|
||||
NOT_A_PORT, NOT_A_PORT, (uint16_t)&PORTB, (uint16_t)&PORTC, (uint16_t)&PORTD, (uint16_t)&PORTE, (uint16_t)&PORTF,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PINB,
|
||||
(uint16_t) &PINC,
|
||||
(uint16_t) &PIND,
|
||||
(uint16_t) &PINE,
|
||||
(uint16_t) &PINF,
|
||||
NOT_A_PORT, NOT_A_PORT, (uint16_t)&PINB, (uint16_t)&PINC, (uint16_t)&PIND, (uint16_t)&PINE, (uint16_t)&PINF,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||
PD, // D0 - PD2
|
||||
PD, // D1 - PD3
|
||||
PD, // D2 - PD1
|
||||
PD, // D3 - PD0
|
||||
PD, // D4 - PD4
|
||||
PC, // D5 - PC6
|
||||
PD, // D6 - PD7
|
||||
PE, // D7 - PE6
|
||||
PD, // D0 - PD2
|
||||
PD, // D1 - PD3
|
||||
PD, // D2 - PD1
|
||||
PD, // D3 - PD0
|
||||
PD, // D4 - PD4
|
||||
PC, // D5 - PC6
|
||||
PD, // D6 - PD7
|
||||
PE, // D7 - PE6
|
||||
|
||||
PB, // D8 - PB4
|
||||
PB, // D9 - PB5
|
||||
PB, // D10 - PB6
|
||||
PB, // D11 - PB7
|
||||
PD, // D12 - PD6
|
||||
PC, // D13 - PC7
|
||||
PB, // D8 - PB4
|
||||
PB, // D9 - PB5
|
||||
PB, // D10 - PB6
|
||||
PB, // D11 - PB7
|
||||
PD, // D12 - PD6
|
||||
PC, // D13 - PC7
|
||||
|
||||
PB, // D14 - MISO - PB3
|
||||
PB, // D15 - SCK - PB1
|
||||
PB, // D16 - MOSI - PB2
|
||||
PB, // D17 - SS - PB0
|
||||
PB, // D14 - MISO - PB3
|
||||
PB, // D15 - SCK - PB1
|
||||
PB, // D16 - MOSI - PB2
|
||||
PB, // D17 - SS - PB0
|
||||
|
||||
PF, // D18 - A0 - PF7
|
||||
PF, // D19 - A1 - PF6
|
||||
PF, // D20 - A2 - PF5
|
||||
PF, // D21 - A3 - PF4
|
||||
PF, // D22 - A4 - PF1
|
||||
PF, // D23 - A5 - PF0
|
||||
PF, // D18 - A0 - PF7
|
||||
PF, // D19 - A1 - PF6
|
||||
PF, // D20 - A2 - PF5
|
||||
PF, // D21 - A3 - PF4
|
||||
PF, // D22 - A4 - PF1
|
||||
PF, // D23 - A5 - PF0
|
||||
|
||||
PD, // D24 - PD5
|
||||
PD, // D25 / D6 - A7 - PD7
|
||||
PB, // D26 / D8 - A8 - PB4
|
||||
PB, // D27 / D9 - A9 - PB5
|
||||
PB, // D28 / D10 - A10 - PB6
|
||||
PD, // D29 / D12 - A11 - PD6
|
||||
PD, // D24 - PD5
|
||||
PD, // D25 / D6 - A7 - PD7
|
||||
PB, // D26 / D8 - A8 - PB4
|
||||
PB, // D27 / D9 - A9 - PB5
|
||||
PB, // D28 / D10 - A10 - PB6
|
||||
PD, // D29 / D12 - A11 - PD6
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||
_BV(2), // D0 - PD2
|
||||
_BV(3), // D1 - PD3
|
||||
_BV(1), // D2 - PD1
|
||||
_BV(0), // D3 - PD0
|
||||
_BV(4), // D4 - PD4
|
||||
_BV(6), // D5 - PC6
|
||||
_BV(7), // D6 - PD7
|
||||
_BV(6), // D7 - PE6
|
||||
_BV(2), // D0 - PD2
|
||||
_BV(3), // D1 - PD3
|
||||
_BV(1), // D2 - PD1
|
||||
_BV(0), // D3 - PD0
|
||||
_BV(4), // D4 - PD4
|
||||
_BV(6), // D5 - PC6
|
||||
_BV(7), // D6 - PD7
|
||||
_BV(6), // D7 - PE6
|
||||
|
||||
_BV(4), // D8 - PB4
|
||||
_BV(5), // D9 - PB5
|
||||
_BV(6), // D10 - PB6
|
||||
_BV(7), // D11 - PB7
|
||||
_BV(6), // D12 - PD6
|
||||
_BV(7), // D13 - PC7
|
||||
_BV(4), // D8 - PB4
|
||||
_BV(5), // D9 - PB5
|
||||
_BV(6), // D10 - PB6
|
||||
_BV(7), // D11 - PB7
|
||||
_BV(6), // D12 - PD6
|
||||
_BV(7), // D13 - PC7
|
||||
|
||||
_BV(3), // D14 - MISO - PB3
|
||||
_BV(1), // D15 - SCK - PB1
|
||||
_BV(2), // D16 - MOSI - PB2
|
||||
_BV(0), // D17 - SS - PB0
|
||||
_BV(3), // D14 - MISO - PB3
|
||||
_BV(1), // D15 - SCK - PB1
|
||||
_BV(2), // D16 - MOSI - PB2
|
||||
_BV(0), // D17 - SS - PB0
|
||||
|
||||
_BV(7), // D18 - A0 - PF7
|
||||
_BV(6), // D19 - A1 - PF6
|
||||
_BV(5), // D20 - A2 - PF5
|
||||
_BV(4), // D21 - A3 - PF4
|
||||
_BV(1), // D22 - A4 - PF1
|
||||
_BV(0), // D23 - A5 - PF0
|
||||
_BV(7), // D18 - A0 - PF7
|
||||
_BV(6), // D19 - A1 - PF6
|
||||
_BV(5), // D20 - A2 - PF5
|
||||
_BV(4), // D21 - A3 - PF4
|
||||
_BV(1), // D22 - A4 - PF1
|
||||
_BV(0), // D23 - A5 - PF0
|
||||
|
||||
_BV(5), // D24 - PD5
|
||||
_BV(7), // D25 / D6 - A7 - PD7
|
||||
_BV(4), // D26 / D8 - A8 - PB4
|
||||
_BV(5), // D27 / D9 - A9 - PB5
|
||||
_BV(6), // D28 / D10 - A10 - PB6
|
||||
_BV(6), // D29 / D12 - A11 - PD6
|
||||
_BV(5), // D24 - PD5
|
||||
_BV(7), // D25 / D6 - A7 - PD7
|
||||
_BV(4), // D26 / D8 - A8 - PB4
|
||||
_BV(5), // D27 / D9 - A9 - PB5
|
||||
_BV(6), // D28 / D10 - A10 - PB6
|
||||
_BV(6), // D29 / D12 - A11 - PD6
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
TIMER0B, /* 3 */
|
||||
NOT_ON_TIMER,
|
||||
TIMER3A, /* 5 */
|
||||
TIMER4D, /* 6 */
|
||||
NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, TIMER0B, /* 3 */
|
||||
NOT_ON_TIMER, TIMER3A, /* 5 */
|
||||
TIMER4D, /* 6 */
|
||||
NOT_ON_TIMER,
|
||||
|
||||
NOT_ON_TIMER,
|
||||
TIMER1A, /* 9 */
|
||||
TIMER1B, /* 10 */
|
||||
TIMER0A, /* 11 */
|
||||
NOT_ON_TIMER, TIMER1A, /* 9 */
|
||||
TIMER1B, /* 10 */
|
||||
TIMER0A, /* 11 */
|
||||
|
||||
NOT_ON_TIMER,
|
||||
TIMER4A, /* 13 */
|
||||
NOT_ON_TIMER, TIMER4A, /* 13 */
|
||||
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER,
|
||||
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
|
||||
7, // A0 PF7 ADC7
|
||||
6, // A1 PF6 ADC6
|
||||
5, // A2 PF5 ADC5
|
||||
4, // A3 PF4 ADC4
|
||||
1, // A4 PF1 ADC1
|
||||
0, // A5 PF0 ADC0
|
||||
8, // A6 D4 PD4 ADC8
|
||||
10, // A7 D6 PD7 ADC10
|
||||
11, // A8 D8 PB4 ADC11
|
||||
12, // A9 D9 PB5 ADC12
|
||||
13, // A10 D10 PB6 ADC13
|
||||
9 // A11 D12 PD6 ADC9
|
||||
7, // A0 PF7 ADC7
|
||||
6, // A1 PF6 ADC6
|
||||
5, // A2 PF5 ADC5
|
||||
4, // A3 PF4 ADC4
|
||||
1, // A4 PF1 ADC1
|
||||
0, // A5 PF0 ADC0
|
||||
8, // A6 D4 PD4 ADC8
|
||||
10, // A7 D6 PD7 ADC10
|
||||
11, // A8 D8 PB4 ADC11
|
||||
12, // A9 D9 PB5 ADC12
|
||||
13, // A10 D10 PB6 ADC13
|
||||
9 // A11 D12 PD6 ADC9
|
||||
};
|
||||
|
||||
#endif /* ARDUINO_MAIN */
|
||||
@ -354,9 +316,9 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
||||
// pins are NOT connected to anything by default.
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_USBVIRTUAL Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial1
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial1
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_USBVIRTUAL Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial1
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial1
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
|
@ -1,325 +1,320 @@
|
||||
#ifdef SSD1306OLED
|
||||
|
||||
#include "ssd1306.h"
|
||||
#include "i2c.h"
|
||||
#include <string.h>
|
||||
#include "print.h"
|
||||
#include "glcdfont.c"
|
||||
#ifdef ADAFRUIT_BLE_ENABLE
|
||||
#include "adafruit_ble.h"
|
||||
#endif
|
||||
#ifdef PROTOCOL_LUFA
|
||||
#include "lufa.h"
|
||||
#endif
|
||||
#include "sendchar.h"
|
||||
#include "timer.h"
|
||||
# include "ssd1306.h"
|
||||
# include "i2c.h"
|
||||
# include <string.h>
|
||||
# include "print.h"
|
||||
# include "glcdfont.c"
|
||||
# ifdef ADAFRUIT_BLE_ENABLE
|
||||
# include "adafruit_ble.h"
|
||||
# endif
|
||||
# ifdef PROTOCOL_LUFA
|
||||
# include "lufa.h"
|
||||
# endif
|
||||
# include "sendchar.h"
|
||||
# include "timer.h"
|
||||
|
||||
// Set this to 1 to help diagnose early startup problems
|
||||
// when testing power-on with ble. Turn it off otherwise,
|
||||
// as the latency of printing most of the debug info messes
|
||||
// with the matrix scan, causing keys to drop.
|
||||
#define DEBUG_TO_SCREEN 0
|
||||
# define DEBUG_TO_SCREEN 0
|
||||
|
||||
//static uint16_t last_battery_update;
|
||||
//static uint32_t vbat;
|
||||
// static uint16_t last_battery_update;
|
||||
// static uint32_t vbat;
|
||||
//#define BatteryUpdateInterval 10000 /* milliseconds */
|
||||
#define ScreenOffInterval 300000 /* milliseconds */
|
||||
#if DEBUG_TO_SCREEN
|
||||
# define ScreenOffInterval 300000 /* milliseconds */
|
||||
# if DEBUG_TO_SCREEN
|
||||
static uint8_t displaying;
|
||||
#endif
|
||||
# endif
|
||||
static uint16_t last_flush;
|
||||
|
||||
// Write command sequence.
|
||||
// Returns true on success.
|
||||
static inline bool _send_cmd1(uint8_t cmd) {
|
||||
bool res = false;
|
||||
bool res = false;
|
||||
|
||||
if (i2c_start_write(SSD1306_ADDRESS)) {
|
||||
xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
|
||||
goto done;
|
||||
}
|
||||
if (i2c_start_write(SSD1306_ADDRESS)) {
|
||||
xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (i2c_master_write(0x0 /* command byte follows */)) {
|
||||
print("failed to write control byte\n");
|
||||
if (i2c_master_write(0x0 /* command byte follows */)) {
|
||||
print("failed to write control byte\n");
|
||||
|
||||
goto done;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (i2c_master_write(cmd)) {
|
||||
xprintf("failed to write command %d\n", cmd);
|
||||
goto done;
|
||||
}
|
||||
res = true;
|
||||
if (i2c_master_write(cmd)) {
|
||||
xprintf("failed to write command %d\n", cmd);
|
||||
goto done;
|
||||
}
|
||||
res = true;
|
||||
done:
|
||||
i2c_master_stop();
|
||||
return res;
|
||||
i2c_master_stop();
|
||||
return res;
|
||||
}
|
||||
|
||||
// Write 2-byte command sequence.
|
||||
// Returns true on success
|
||||
static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
|
||||
if (!_send_cmd1(cmd)) {
|
||||
return false;
|
||||
}
|
||||
return _send_cmd1(opr);
|
||||
if (!_send_cmd1(cmd)) {
|
||||
return false;
|
||||
}
|
||||
return _send_cmd1(opr);
|
||||
}
|
||||
|
||||
// Write 3-byte command sequence.
|
||||
// Returns true on success
|
||||
static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
|
||||
if (!_send_cmd1(cmd)) {
|
||||
return false;
|
||||
}
|
||||
if (!_send_cmd1(opr1)) {
|
||||
return false;
|
||||
}
|
||||
return _send_cmd1(opr2);
|
||||
if (!_send_cmd1(cmd)) {
|
||||
return false;
|
||||
}
|
||||
if (!_send_cmd1(opr1)) {
|
||||
return false;
|
||||
}
|
||||
return _send_cmd1(opr2);
|
||||
}
|
||||
|
||||
#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;}
|
||||
#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;}
|
||||
#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;}
|
||||
# define send_cmd1(c) \
|
||||
if (!_send_cmd1(c)) { \
|
||||
goto done; \
|
||||
}
|
||||
# define send_cmd2(c, o) \
|
||||
if (!_send_cmd2(c, o)) { \
|
||||
goto done; \
|
||||
}
|
||||
# define send_cmd3(c, o1, o2) \
|
||||
if (!_send_cmd3(c, o1, o2)) { \
|
||||
goto done; \
|
||||
}
|
||||
|
||||
static void clear_display(void) {
|
||||
matrix_clear(&display);
|
||||
matrix_clear(&display);
|
||||
|
||||
// Clear all of the display bits (there can be random noise
|
||||
// in the RAM on startup)
|
||||
send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
|
||||
send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
|
||||
// Clear all of the display bits (there can be random noise
|
||||
// in the RAM on startup)
|
||||
send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
|
||||
send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
|
||||
|
||||
if (i2c_start_write(SSD1306_ADDRESS)) {
|
||||
goto done;
|
||||
}
|
||||
if (i2c_master_write(0x40)) {
|
||||
// Data mode
|
||||
goto done;
|
||||
}
|
||||
for (uint8_t row = 0; row < MatrixRows; ++row) {
|
||||
for (uint8_t col = 0; col < DisplayWidth; ++col) {
|
||||
i2c_master_write(0);
|
||||
if (i2c_start_write(SSD1306_ADDRESS)) {
|
||||
goto done;
|
||||
}
|
||||
if (i2c_master_write(0x40)) {
|
||||
// Data mode
|
||||
goto done;
|
||||
}
|
||||
for (uint8_t row = 0; row < MatrixRows; ++row) {
|
||||
for (uint8_t col = 0; col < DisplayWidth; ++col) {
|
||||
i2c_master_write(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
display.dirty = false;
|
||||
display.dirty = false;
|
||||
|
||||
done:
|
||||
i2c_master_stop();
|
||||
i2c_master_stop();
|
||||
}
|
||||
|
||||
#if DEBUG_TO_SCREEN
|
||||
#undef sendchar
|
||||
# if DEBUG_TO_SCREEN
|
||||
# undef sendchar
|
||||
static int8_t capture_sendchar(uint8_t c) {
|
||||
sendchar(c);
|
||||
iota_gfx_write_char(c);
|
||||
sendchar(c);
|
||||
iota_gfx_write_char(c);
|
||||
|
||||
if (!displaying) {
|
||||
iota_gfx_flush();
|
||||
}
|
||||
return 0;
|
||||
if (!displaying) {
|
||||
iota_gfx_flush();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
bool iota_gfx_init(void) {
|
||||
bool success = false;
|
||||
bool success = false;
|
||||
|
||||
send_cmd1(DisplayOff);
|
||||
send_cmd2(SetDisplayClockDiv, 0x80);
|
||||
send_cmd2(SetMultiPlex, DisplayHeight - 1);
|
||||
send_cmd1(DisplayOff);
|
||||
send_cmd2(SetDisplayClockDiv, 0x80);
|
||||
send_cmd2(SetMultiPlex, DisplayHeight - 1);
|
||||
|
||||
send_cmd2(SetDisplayOffset, 0);
|
||||
send_cmd2(SetDisplayOffset, 0);
|
||||
|
||||
send_cmd1(SetStartLine | 0x0);
|
||||
send_cmd2(SetChargePump, 0x14 /* Enable */);
|
||||
send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
|
||||
|
||||
send_cmd1(SetStartLine | 0x0);
|
||||
send_cmd2(SetChargePump, 0x14 /* Enable */);
|
||||
send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
|
||||
# ifdef OLED_ROTATE180
|
||||
// the following Flip the display orientation 180 degrees
|
||||
send_cmd1(SegRemap);
|
||||
send_cmd1(ComScanInc);
|
||||
# endif
|
||||
# ifndef OLED_ROTATE180
|
||||
// Flips the display orientation 0 degrees
|
||||
send_cmd1(SegRemap | 0x1);
|
||||
send_cmd1(ComScanDec);
|
||||
# endif
|
||||
|
||||
#ifdef OLED_ROTATE180
|
||||
// the following Flip the display orientation 180 degrees
|
||||
send_cmd1(SegRemap);
|
||||
send_cmd1(ComScanInc);
|
||||
#endif
|
||||
#ifndef OLED_ROTATE180
|
||||
// Flips the display orientation 0 degrees
|
||||
send_cmd1(SegRemap | 0x1);
|
||||
send_cmd1(ComScanDec);
|
||||
#endif
|
||||
|
||||
send_cmd2(SetComPins, 0x2);
|
||||
send_cmd2(SetContrast, 0x8f);
|
||||
send_cmd2(SetPreCharge, 0xf1);
|
||||
send_cmd2(SetVComDetect, 0x40);
|
||||
send_cmd1(DisplayAllOnResume);
|
||||
send_cmd1(NormalDisplay);
|
||||
send_cmd1(DeActivateScroll);
|
||||
send_cmd1(DisplayOn);
|
||||
send_cmd2(SetComPins, 0x2);
|
||||
send_cmd2(SetContrast, 0x8f);
|
||||
send_cmd2(SetPreCharge, 0xf1);
|
||||
send_cmd2(SetVComDetect, 0x40);
|
||||
send_cmd1(DisplayAllOnResume);
|
||||
send_cmd1(NormalDisplay);
|
||||
send_cmd1(DeActivateScroll);
|
||||
send_cmd1(DisplayOn);
|
||||
|
||||
send_cmd2(SetContrast, 0); // Dim
|
||||
send_cmd2(SetContrast, 0); // Dim
|
||||
|
||||
clear_display();
|
||||
clear_display();
|
||||
|
||||
success = true;
|
||||
success = true;
|
||||
|
||||
iota_gfx_flush();
|
||||
iota_gfx_flush();
|
||||
|
||||
#if DEBUG_TO_SCREEN
|
||||
print_set_sendchar(capture_sendchar);
|
||||
#endif
|
||||
# if DEBUG_TO_SCREEN
|
||||
print_set_sendchar(capture_sendchar);
|
||||
# endif
|
||||
|
||||
done:
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
bool iota_gfx_off(void) {
|
||||
bool success = false;
|
||||
bool success = false;
|
||||
|
||||
send_cmd1(DisplayOff);
|
||||
success = true;
|
||||
send_cmd1(DisplayOff);
|
||||
success = true;
|
||||
|
||||
done:
|
||||
return success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool iota_gfx_on(void) {
|
||||
bool success = false;
|
||||
bool success = false;
|
||||
|
||||
send_cmd1(DisplayOn);
|
||||
success = true;
|
||||
send_cmd1(DisplayOn);
|
||||
success = true;
|
||||
|
||||
done:
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
|
||||
*matrix->cursor = c;
|
||||
++matrix->cursor;
|
||||
*matrix->cursor = c;
|
||||
++matrix->cursor;
|
||||
|
||||
if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
|
||||
// We went off the end; scroll the display upwards by one line
|
||||
memmove(&matrix->display[0], &matrix->display[1],
|
||||
MatrixCols * (MatrixRows - 1));
|
||||
matrix->cursor = &matrix->display[MatrixRows - 1][0];
|
||||
memset(matrix->cursor, ' ', MatrixCols);
|
||||
}
|
||||
if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
|
||||
// We went off the end; scroll the display upwards by one line
|
||||
memmove(&matrix->display[0], &matrix->display[1], MatrixCols * (MatrixRows - 1));
|
||||
matrix->cursor = &matrix->display[MatrixRows - 1][0];
|
||||
memset(matrix->cursor, ' ', MatrixCols);
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
|
||||
matrix->dirty = true;
|
||||
matrix->dirty = true;
|
||||
|
||||
if (c == '\n') {
|
||||
// Clear to end of line from the cursor and then move to the
|
||||
// start of the next line
|
||||
uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
|
||||
if (c == '\n') {
|
||||
// Clear to end of line from the cursor and then move to the
|
||||
// start of the next line
|
||||
uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
|
||||
|
||||
while (cursor_col++ < MatrixCols) {
|
||||
matrix_write_char_inner(matrix, ' ');
|
||||
while (cursor_col++ < MatrixCols) {
|
||||
matrix_write_char_inner(matrix, ' ');
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_write_char_inner(matrix, c);
|
||||
matrix_write_char_inner(matrix, c);
|
||||
}
|
||||
|
||||
void iota_gfx_write_char(uint8_t c) {
|
||||
matrix_write_char(&display, c);
|
||||
}
|
||||
void iota_gfx_write_char(uint8_t c) { matrix_write_char(&display, c); }
|
||||
|
||||
void matrix_write(struct CharacterMatrix *matrix, const char *data) {
|
||||
const char *end = data + strlen(data);
|
||||
while (data < end) {
|
||||
matrix_write_char(matrix, *data);
|
||||
++data;
|
||||
}
|
||||
const char *end = data + strlen(data);
|
||||
while (data < end) {
|
||||
matrix_write_char(matrix, *data);
|
||||
++data;
|
||||
}
|
||||
}
|
||||
|
||||
void iota_gfx_write(const char *data) {
|
||||
matrix_write(&display, data);
|
||||
}
|
||||
void iota_gfx_write(const char *data) { matrix_write(&display, data); }
|
||||
|
||||
void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
|
||||
while (true) {
|
||||
uint8_t c = pgm_read_byte(data);
|
||||
if (c == 0) {
|
||||
return;
|
||||
while (true) {
|
||||
uint8_t c = pgm_read_byte(data);
|
||||
if (c == 0) {
|
||||
return;
|
||||
}
|
||||
matrix_write_char(matrix, c);
|
||||
++data;
|
||||
}
|
||||
matrix_write_char(matrix, c);
|
||||
++data;
|
||||
}
|
||||
}
|
||||
|
||||
void iota_gfx_write_P(const char *data) {
|
||||
matrix_write_P(&display, data);
|
||||
}
|
||||
void iota_gfx_write_P(const char *data) { matrix_write_P(&display, data); }
|
||||
|
||||
void matrix_clear(struct CharacterMatrix *matrix) {
|
||||
memset(matrix->display, ' ', sizeof(matrix->display));
|
||||
matrix->cursor = &matrix->display[0][0];
|
||||
matrix->dirty = true;
|
||||
memset(matrix->display, ' ', sizeof(matrix->display));
|
||||
matrix->cursor = &matrix->display[0][0];
|
||||
matrix->dirty = true;
|
||||
}
|
||||
|
||||
void iota_gfx_clear_screen(void) {
|
||||
matrix_clear(&display);
|
||||
}
|
||||
void iota_gfx_clear_screen(void) { matrix_clear(&display); }
|
||||
|
||||
void matrix_render(struct CharacterMatrix *matrix) {
|
||||
last_flush = timer_read();
|
||||
iota_gfx_on();
|
||||
#if DEBUG_TO_SCREEN
|
||||
++displaying;
|
||||
#endif
|
||||
last_flush = timer_read();
|
||||
iota_gfx_on();
|
||||
# if DEBUG_TO_SCREEN
|
||||
++displaying;
|
||||
# endif
|
||||
|
||||
// Move to the home position
|
||||
send_cmd3(PageAddr, 0, MatrixRows - 1);
|
||||
send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
|
||||
// Move to the home position
|
||||
send_cmd3(PageAddr, 0, MatrixRows - 1);
|
||||
send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
|
||||
|
||||
if (i2c_start_write(SSD1306_ADDRESS)) {
|
||||
goto done;
|
||||
}
|
||||
if (i2c_master_write(0x40)) {
|
||||
// Data mode
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (uint8_t row = 0; row < MatrixRows; ++row) {
|
||||
for (uint8_t col = 0; col < MatrixCols; ++col) {
|
||||
const uint8_t *glyph = font + (matrix->display[row][col] * (FontWidth - 1));
|
||||
|
||||
for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++glyphCol) {
|
||||
uint8_t colBits = pgm_read_byte(glyph + glyphCol);
|
||||
i2c_master_write(colBits);
|
||||
}
|
||||
|
||||
// 1 column of space between chars (it's not included in the glyph)
|
||||
i2c_master_write(0);
|
||||
if (i2c_start_write(SSD1306_ADDRESS)) {
|
||||
goto done;
|
||||
}
|
||||
if (i2c_master_write(0x40)) {
|
||||
// Data mode
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
matrix->dirty = false;
|
||||
for (uint8_t row = 0; row < MatrixRows; ++row) {
|
||||
for (uint8_t col = 0; col < MatrixCols; ++col) {
|
||||
const uint8_t *glyph = font + (matrix->display[row][col] * (FontWidth - 1));
|
||||
|
||||
for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++glyphCol) {
|
||||
uint8_t colBits = pgm_read_byte(glyph + glyphCol);
|
||||
i2c_master_write(colBits);
|
||||
}
|
||||
|
||||
// 1 column of space between chars (it's not included in the glyph)
|
||||
i2c_master_write(0);
|
||||
}
|
||||
}
|
||||
|
||||
matrix->dirty = false;
|
||||
|
||||
done:
|
||||
i2c_master_stop();
|
||||
#if DEBUG_TO_SCREEN
|
||||
--displaying;
|
||||
#endif
|
||||
i2c_master_stop();
|
||||
# if DEBUG_TO_SCREEN
|
||||
--displaying;
|
||||
# endif
|
||||
}
|
||||
|
||||
void iota_gfx_flush(void) {
|
||||
matrix_render(&display);
|
||||
}
|
||||
void iota_gfx_flush(void) { matrix_render(&display); }
|
||||
|
||||
__attribute__ ((weak))
|
||||
void iota_gfx_task_user(void) {
|
||||
}
|
||||
__attribute__((weak)) void iota_gfx_task_user(void) {}
|
||||
|
||||
void iota_gfx_task(void) {
|
||||
iota_gfx_task_user();
|
||||
iota_gfx_task_user();
|
||||
|
||||
if (display.dirty) {
|
||||
iota_gfx_flush();
|
||||
}
|
||||
if (display.dirty) {
|
||||
iota_gfx_flush();
|
||||
}
|
||||
|
||||
if (timer_elapsed(last_flush) > ScreenOffInterval) {
|
||||
iota_gfx_off();
|
||||
}
|
||||
if (timer_elapsed(last_flush) > ScreenOffInterval) {
|
||||
iota_gfx_off();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -7,49 +7,49 @@
|
||||
#include "config.h"
|
||||
|
||||
enum ssd1306_cmds {
|
||||
DisplayOff = 0xAE,
|
||||
DisplayOn = 0xAF,
|
||||
DisplayOff = 0xAE,
|
||||
DisplayOn = 0xAF,
|
||||
|
||||
SetContrast = 0x81,
|
||||
DisplayAllOnResume = 0xA4,
|
||||
SetContrast = 0x81,
|
||||
DisplayAllOnResume = 0xA4,
|
||||
|
||||
DisplayAllOn = 0xA5,
|
||||
NormalDisplay = 0xA6,
|
||||
InvertDisplay = 0xA7,
|
||||
SetDisplayOffset = 0xD3,
|
||||
SetComPins = 0xda,
|
||||
SetVComDetect = 0xdb,
|
||||
SetDisplayClockDiv = 0xD5,
|
||||
SetPreCharge = 0xd9,
|
||||
SetMultiPlex = 0xa8,
|
||||
SetLowColumn = 0x00,
|
||||
SetHighColumn = 0x10,
|
||||
SetStartLine = 0x40,
|
||||
DisplayAllOn = 0xA5,
|
||||
NormalDisplay = 0xA6,
|
||||
InvertDisplay = 0xA7,
|
||||
SetDisplayOffset = 0xD3,
|
||||
SetComPins = 0xda,
|
||||
SetVComDetect = 0xdb,
|
||||
SetDisplayClockDiv = 0xD5,
|
||||
SetPreCharge = 0xd9,
|
||||
SetMultiPlex = 0xa8,
|
||||
SetLowColumn = 0x00,
|
||||
SetHighColumn = 0x10,
|
||||
SetStartLine = 0x40,
|
||||
|
||||
SetMemoryMode = 0x20,
|
||||
ColumnAddr = 0x21,
|
||||
PageAddr = 0x22,
|
||||
SetMemoryMode = 0x20,
|
||||
ColumnAddr = 0x21,
|
||||
PageAddr = 0x22,
|
||||
|
||||
ComScanInc = 0xc0,
|
||||
ComScanDec = 0xc8,
|
||||
SegRemap = 0xa0,
|
||||
SetChargePump = 0x8d,
|
||||
ExternalVcc = 0x01,
|
||||
SwitchCapVcc = 0x02,
|
||||
ComScanInc = 0xc0,
|
||||
ComScanDec = 0xc8,
|
||||
SegRemap = 0xa0,
|
||||
SetChargePump = 0x8d,
|
||||
ExternalVcc = 0x01,
|
||||
SwitchCapVcc = 0x02,
|
||||
|
||||
ActivateScroll = 0x2f,
|
||||
DeActivateScroll = 0x2e,
|
||||
SetVerticalScrollArea = 0xa3,
|
||||
RightHorizontalScroll = 0x26,
|
||||
LeftHorizontalScroll = 0x27,
|
||||
VerticalAndRightHorizontalScroll = 0x29,
|
||||
VerticalAndLeftHorizontalScroll = 0x2a,
|
||||
ActivateScroll = 0x2f,
|
||||
DeActivateScroll = 0x2e,
|
||||
SetVerticalScrollArea = 0xa3,
|
||||
RightHorizontalScroll = 0x26,
|
||||
LeftHorizontalScroll = 0x27,
|
||||
VerticalAndRightHorizontalScroll = 0x29,
|
||||
VerticalAndLeftHorizontalScroll = 0x2a,
|
||||
};
|
||||
|
||||
// Controls the SSD1306 128x32 OLED display via i2c
|
||||
|
||||
#ifndef SSD1306_ADDRESS
|
||||
#define SSD1306_ADDRESS 0x3C
|
||||
# define SSD1306_ADDRESS 0x3C
|
||||
#endif
|
||||
|
||||
#define DisplayHeight 32
|
||||
@ -62,9 +62,9 @@ enum ssd1306_cmds {
|
||||
#define MatrixCols (DisplayWidth / FontWidth)
|
||||
|
||||
struct CharacterMatrix {
|
||||
uint8_t display[MatrixRows][MatrixCols];
|
||||
uint8_t *cursor;
|
||||
bool dirty;
|
||||
uint8_t display[MatrixRows][MatrixCols];
|
||||
uint8_t *cursor;
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
struct CharacterMatrix display;
|
||||
@ -88,6 +88,4 @@ void matrix_write(struct CharacterMatrix *matrix, const char *data);
|
||||
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
|
||||
void matrix_render(struct CharacterMatrix *matrix);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,25 +1,25 @@
|
||||
/*
|
||||
* light weight WS2812 lib V2.0b
|
||||
*
|
||||
* Controls WS2811/WS2812/WS2812B RGB-LEDs
|
||||
* Author: Tim (cpldcpu@gmail.com)
|
||||
*
|
||||
* Jan 18th, 2014 v2.0b Initial Version
|
||||
* Nov 29th, 2015 v2.3 Added SK6812RGBW support
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* light weight WS2812 lib V2.0b
|
||||
*
|
||||
* Controls WS2811/WS2812/WS2812B RGB-LEDs
|
||||
* Author: Tim (cpldcpu@gmail.com)
|
||||
*
|
||||
* Jan 18th, 2014 v2.0b Initial Version
|
||||
* Nov 29th, 2015 v2.3 Added SK6812RGBW support
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ws2812.h"
|
||||
#include <avr/interrupt.h>
|
||||
@ -30,44 +30,40 @@
|
||||
#if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE)
|
||||
// LED color buffer
|
||||
LED_TYPE led[DRIVER_LED_TOTAL];
|
||||
#define LED_ARRAY led
|
||||
# define LED_ARRAY led
|
||||
#endif
|
||||
|
||||
#ifdef RGBW_BB_TWI
|
||||
|
||||
// Port for the I2C
|
||||
#define I2C_DDR DDRD
|
||||
#define I2C_PIN PIND
|
||||
#define I2C_PORT PORTD
|
||||
# define I2C_DDR DDRD
|
||||
# define I2C_PIN PIND
|
||||
# define I2C_PORT PORTD
|
||||
|
||||
// Pins to be used in the bit banging
|
||||
#define I2C_CLK 0
|
||||
#define I2C_DAT 1
|
||||
# define I2C_CLK 0
|
||||
# define I2C_DAT 1
|
||||
|
||||
#define I2C_DATA_HI()\
|
||||
I2C_DDR &= ~ (1 << I2C_DAT);\
|
||||
I2C_PORT |= (1 << I2C_DAT);
|
||||
#define I2C_DATA_LO()\
|
||||
I2C_DDR |= (1 << I2C_DAT);\
|
||||
I2C_PORT &= ~ (1 << I2C_DAT);
|
||||
# define I2C_DATA_HI() \
|
||||
I2C_DDR &= ~(1 << I2C_DAT); \
|
||||
I2C_PORT |= (1 << I2C_DAT);
|
||||
# define I2C_DATA_LO() \
|
||||
I2C_DDR |= (1 << I2C_DAT); \
|
||||
I2C_PORT &= ~(1 << I2C_DAT);
|
||||
|
||||
#define I2C_CLOCK_HI()\
|
||||
I2C_DDR &= ~ (1 << I2C_CLK);\
|
||||
I2C_PORT |= (1 << I2C_CLK);
|
||||
#define I2C_CLOCK_LO()\
|
||||
I2C_DDR |= (1 << I2C_CLK);\
|
||||
I2C_PORT &= ~ (1 << I2C_CLK);
|
||||
# define I2C_CLOCK_HI() \
|
||||
I2C_DDR &= ~(1 << I2C_CLK); \
|
||||
I2C_PORT |= (1 << I2C_CLK);
|
||||
# define I2C_CLOCK_LO() \
|
||||
I2C_DDR |= (1 << I2C_CLK); \
|
||||
I2C_PORT &= ~(1 << I2C_CLK);
|
||||
|
||||
#define I2C_DELAY 1
|
||||
# define I2C_DELAY 1
|
||||
|
||||
void I2C_WriteBit(unsigned char c)
|
||||
{
|
||||
if (c > 0)
|
||||
{
|
||||
void I2C_WriteBit(unsigned char c) {
|
||||
if (c > 0) {
|
||||
I2C_DATA_HI();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
I2C_DATA_LO();
|
||||
}
|
||||
|
||||
@ -77,8 +73,7 @@ void I2C_WriteBit(unsigned char c)
|
||||
I2C_CLOCK_LO();
|
||||
_delay_us(I2C_DELAY);
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
if (c > 0) {
|
||||
I2C_DATA_LO();
|
||||
}
|
||||
|
||||
@ -87,9 +82,8 @@ void I2C_WriteBit(unsigned char c)
|
||||
|
||||
// Inits bitbanging port, must be called before using the functions below
|
||||
//
|
||||
void I2C_Init(void)
|
||||
{
|
||||
I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
|
||||
void I2C_Init(void) {
|
||||
I2C_PORT &= ~((1 << I2C_DAT) | (1 << I2C_CLK));
|
||||
|
||||
I2C_CLOCK_HI();
|
||||
I2C_DATA_HI();
|
||||
@ -99,10 +93,9 @@ void I2C_Init(void)
|
||||
|
||||
// Send a START Condition
|
||||
//
|
||||
void I2C_Start(void)
|
||||
{
|
||||
void I2C_Start(void) {
|
||||
// set both to high at the same time
|
||||
I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
|
||||
I2C_DDR &= ~((1 << I2C_DAT) | (1 << I2C_CLK));
|
||||
_delay_us(I2C_DELAY);
|
||||
|
||||
I2C_DATA_LO();
|
||||
@ -114,8 +107,7 @@ void I2C_Start(void)
|
||||
|
||||
// Send a STOP Condition
|
||||
//
|
||||
void I2C_Stop(void)
|
||||
{
|
||||
void I2C_Stop(void) {
|
||||
I2C_CLOCK_HI();
|
||||
_delay_us(I2C_DELAY);
|
||||
|
||||
@ -125,106 +117,91 @@ void I2C_Stop(void)
|
||||
|
||||
// write a byte to the I2C slave device
|
||||
//
|
||||
unsigned char I2C_Write(unsigned char c)
|
||||
{
|
||||
for (char i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char I2C_Write(unsigned char c) {
|
||||
for (char i = 0; i < 8; i++) {
|
||||
I2C_WriteBit(c & 128);
|
||||
|
||||
c <<= 1;
|
||||
}
|
||||
|
||||
|
||||
I2C_WriteBit(0);
|
||||
_delay_us(I2C_DELAY);
|
||||
_delay_us(I2C_DELAY);
|
||||
|
||||
// _delay_us(I2C_DELAY);
|
||||
//return I2C_ReadBit();
|
||||
// return I2C_ReadBit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
// Set an led in the buffer to a color
|
||||
void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) {
|
||||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
}
|
||||
|
||||
void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
for (int i = 0; i < sizeof(led)/sizeof(led[0]); i++) {
|
||||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
}
|
||||
void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b) {
|
||||
for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) {
|
||||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Setleds for standard RGB
|
||||
void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds)
|
||||
{
|
||||
// ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
|
||||
ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF));
|
||||
void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
|
||||
// ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
|
||||
ws2812_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF));
|
||||
}
|
||||
|
||||
void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask)
|
||||
{
|
||||
// ws2812_DDRREG |= pinmask; // Enable DDR
|
||||
// new universal format (DDR)
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
|
||||
void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) {
|
||||
// ws2812_DDRREG |= pinmask; // Enable DDR
|
||||
// new universal format (DDR)
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
|
||||
|
||||
ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask);
|
||||
_delay_us(50);
|
||||
ws2812_sendarray_mask((uint8_t *)ledarray, leds + leds + leds, pinmask);
|
||||
_delay_us(50);
|
||||
}
|
||||
|
||||
// Setleds for SK6812RGBW
|
||||
void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds)
|
||||
{
|
||||
|
||||
#ifdef RGBW_BB_TWI
|
||||
void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
|
||||
#ifdef RGBW_BB_TWI
|
||||
uint8_t sreg_prev, twcr_prev;
|
||||
sreg_prev=SREG;
|
||||
twcr_prev=TWCR;
|
||||
sreg_prev = SREG;
|
||||
twcr_prev = TWCR;
|
||||
cli();
|
||||
TWCR &= ~(1<<TWEN);
|
||||
TWCR &= ~(1 << TWEN);
|
||||
I2C_Init();
|
||||
I2C_Start();
|
||||
I2C_Write(0x84);
|
||||
uint16_t datlen = leds<<2;
|
||||
uint8_t curbyte;
|
||||
uint8_t * data = (uint8_t*)ledarray;
|
||||
uint16_t datlen = leds << 2;
|
||||
uint8_t curbyte;
|
||||
uint8_t *data = (uint8_t *)ledarray;
|
||||
while (datlen--) {
|
||||
curbyte=*data++;
|
||||
I2C_Write(curbyte);
|
||||
curbyte = *data++;
|
||||
I2C_Write(curbyte);
|
||||
}
|
||||
I2C_Stop();
|
||||
SREG=sreg_prev;
|
||||
TWCR=twcr_prev;
|
||||
#endif
|
||||
SREG = sreg_prev;
|
||||
TWCR = twcr_prev;
|
||||
#endif
|
||||
|
||||
// ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
|
||||
// new universal format (DDR)
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
|
||||
|
||||
// ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
|
||||
// new universal format (DDR)
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
|
||||
ws2812_sendarray_mask((uint8_t *)ledarray, leds << 2, _BV(RGB_DI_PIN & 0xF));
|
||||
|
||||
ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
|
||||
|
||||
|
||||
#ifndef RGBW_BB_TWI
|
||||
#ifndef RGBW_BB_TWI
|
||||
_delay_us(80);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void ws2812_sendarray(uint8_t *data,uint16_t datlen)
|
||||
{
|
||||
ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF));
|
||||
}
|
||||
void ws2812_sendarray(uint8_t *data, uint16_t datlen) { ws2812_sendarray_mask(data, datlen, _BV(RGB_DI_PIN & 0xF)); }
|
||||
|
||||
/*
|
||||
This routine writes an array of bytes with RGB values to the Dataout pin
|
||||
@ -232,136 +209,133 @@ void ws2812_sendarray(uint8_t *data,uint16_t datlen)
|
||||
*/
|
||||
|
||||
// Timing in ns
|
||||
#define w_zeropulse 350
|
||||
#define w_onepulse 900
|
||||
#define w_zeropulse 350
|
||||
#define w_onepulse 900
|
||||
#define w_totalperiod 1250
|
||||
|
||||
// Fixed cycles used by the inner loop
|
||||
#define w_fixedlow 2
|
||||
#define w_fixedhigh 4
|
||||
#define w_fixedtotal 8
|
||||
#define w_fixedlow 2
|
||||
#define w_fixedhigh 4
|
||||
#define w_fixedtotal 8
|
||||
|
||||
// Insert NOPs to match the timing, if possible
|
||||
#define w_zerocycles (((F_CPU/1000)*w_zeropulse )/1000000)
|
||||
#define w_onecycles (((F_CPU/1000)*w_onepulse +500000)/1000000)
|
||||
#define w_totalcycles (((F_CPU/1000)*w_totalperiod +500000)/1000000)
|
||||
#define w_zerocycles (((F_CPU / 1000) * w_zeropulse) / 1000000)
|
||||
#define w_onecycles (((F_CPU / 1000) * w_onepulse + 500000) / 1000000)
|
||||
#define w_totalcycles (((F_CPU / 1000) * w_totalperiod + 500000) / 1000000)
|
||||
|
||||
// w1 - nops between rising edge and falling edge - low
|
||||
#define w1 (w_zerocycles-w_fixedlow)
|
||||
#define w1 (w_zerocycles - w_fixedlow)
|
||||
// w2 nops between fe low and fe high
|
||||
#define w2 (w_onecycles-w_fixedhigh-w1)
|
||||
#define w2 (w_onecycles - w_fixedhigh - w1)
|
||||
// w3 nops to complete loop
|
||||
#define w3 (w_totalcycles-w_fixedtotal-w1-w2)
|
||||
#define w3 (w_totalcycles - w_fixedtotal - w1 - w2)
|
||||
|
||||
#if w1>0
|
||||
#define w1_nops w1
|
||||
#if w1 > 0
|
||||
# define w1_nops w1
|
||||
#else
|
||||
#define w1_nops 0
|
||||
# define w1_nops 0
|
||||
#endif
|
||||
|
||||
// The only critical timing parameter is the minimum pulse length of the "0"
|
||||
// Warn or throw error if this timing can not be met with current F_CPU settings.
|
||||
#define w_lowtime ((w1_nops+w_fixedlow)*1000000)/(F_CPU/1000)
|
||||
#if w_lowtime>550
|
||||
#error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
|
||||
#elif w_lowtime>450
|
||||
#warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
|
||||
#warning "Please consider a higher clockspeed, if possible"
|
||||
#define w_lowtime ((w1_nops + w_fixedlow) * 1000000) / (F_CPU / 1000)
|
||||
#if w_lowtime > 550
|
||||
# error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
|
||||
#elif w_lowtime > 450
|
||||
# warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
|
||||
# warning "Please consider a higher clockspeed, if possible"
|
||||
#endif
|
||||
|
||||
#if w2>0
|
||||
#define w2_nops w2
|
||||
#if w2 > 0
|
||||
# define w2_nops w2
|
||||
#else
|
||||
#define w2_nops 0
|
||||
# define w2_nops 0
|
||||
#endif
|
||||
|
||||
#if w3>0
|
||||
#define w3_nops w3
|
||||
#if w3 > 0
|
||||
# define w3_nops w3
|
||||
#else
|
||||
#define w3_nops 0
|
||||
# define w3_nops 0
|
||||
#endif
|
||||
|
||||
#define w_nop1 "nop \n\t"
|
||||
#define w_nop2 "rjmp .+0 \n\t"
|
||||
#define w_nop4 w_nop2 w_nop2
|
||||
#define w_nop8 w_nop4 w_nop4
|
||||
#define w_nop1 "nop \n\t"
|
||||
#define w_nop2 "rjmp .+0 \n\t"
|
||||
#define w_nop4 w_nop2 w_nop2
|
||||
#define w_nop8 w_nop4 w_nop4
|
||||
#define w_nop16 w_nop8 w_nop8
|
||||
|
||||
void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
|
||||
{
|
||||
uint8_t curbyte,ctr,masklo;
|
||||
uint8_t sreg_prev;
|
||||
void inline ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t maskhi) {
|
||||
uint8_t curbyte, ctr, masklo;
|
||||
uint8_t sreg_prev;
|
||||
|
||||
// masklo =~maskhi&ws2812_PORTREG;
|
||||
// maskhi |= ws2812_PORTREG;
|
||||
masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2);
|
||||
maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
|
||||
sreg_prev=SREG;
|
||||
cli();
|
||||
// masklo =~maskhi&ws2812_PORTREG;
|
||||
// maskhi |= ws2812_PORTREG;
|
||||
masklo = ~maskhi & _SFR_IO8((RGB_DI_PIN >> 4) + 2);
|
||||
maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
|
||||
sreg_prev = SREG;
|
||||
cli();
|
||||
|
||||
while (datlen--) {
|
||||
curbyte=(*data++);
|
||||
while (datlen--) {
|
||||
curbyte = (*data++);
|
||||
|
||||
asm volatile(
|
||||
" ldi %0,8 \n\t"
|
||||
"loop%=: \n\t"
|
||||
" out %2,%3 \n\t" // '1' [01] '0' [01] - re
|
||||
#if (w1_nops&1)
|
||||
w_nop1
|
||||
asm volatile(" ldi %0,8 \n\t"
|
||||
"loop%=: \n\t"
|
||||
" out %2,%3 \n\t" // '1' [01] '0' [01] - re
|
||||
#if (w1_nops & 1)
|
||||
w_nop1
|
||||
#endif
|
||||
#if (w1_nops&2)
|
||||
w_nop2
|
||||
#if (w1_nops & 2)
|
||||
w_nop2
|
||||
#endif
|
||||
#if (w1_nops&4)
|
||||
w_nop4
|
||||
#if (w1_nops & 4)
|
||||
w_nop4
|
||||
#endif
|
||||
#if (w1_nops&8)
|
||||
w_nop8
|
||||
#if (w1_nops & 8)
|
||||
w_nop8
|
||||
#endif
|
||||
#if (w1_nops&16)
|
||||
w_nop16
|
||||
#if (w1_nops & 16)
|
||||
w_nop16
|
||||
#endif
|
||||
" sbrs %1,7 \n\t" // '1' [03] '0' [02]
|
||||
" out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low
|
||||
" lsl %1 \n\t" // '1' [04] '0' [04]
|
||||
#if (w2_nops&1)
|
||||
w_nop1
|
||||
" sbrs %1,7 \n\t" // '1' [03] '0' [02]
|
||||
" out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low
|
||||
" lsl %1 \n\t" // '1' [04] '0' [04]
|
||||
#if (w2_nops & 1)
|
||||
w_nop1
|
||||
#endif
|
||||
#if (w2_nops&2)
|
||||
w_nop2
|
||||
#if (w2_nops & 2)
|
||||
w_nop2
|
||||
#endif
|
||||
#if (w2_nops&4)
|
||||
w_nop4
|
||||
#if (w2_nops & 4)
|
||||
w_nop4
|
||||
#endif
|
||||
#if (w2_nops&8)
|
||||
w_nop8
|
||||
#if (w2_nops & 8)
|
||||
w_nop8
|
||||
#endif
|
||||
#if (w2_nops&16)
|
||||
w_nop16
|
||||
#if (w2_nops & 16)
|
||||
w_nop16
|
||||
#endif
|
||||
" out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high
|
||||
#if (w3_nops&1)
|
||||
w_nop1
|
||||
" out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high
|
||||
#if (w3_nops & 1)
|
||||
w_nop1
|
||||
#endif
|
||||
#if (w3_nops&2)
|
||||
w_nop2
|
||||
#if (w3_nops & 2)
|
||||
w_nop2
|
||||
#endif
|
||||
#if (w3_nops&4)
|
||||
w_nop4
|
||||
#if (w3_nops & 4)
|
||||
w_nop4
|
||||
#endif
|
||||
#if (w3_nops&8)
|
||||
w_nop8
|
||||
#if (w3_nops & 8)
|
||||
w_nop8
|
||||
#endif
|
||||
#if (w3_nops&16)
|
||||
w_nop16
|
||||
#if (w3_nops & 16)
|
||||
w_nop16
|
||||
#endif
|
||||
|
||||
" dec %0 \n\t" // '1' [+2] '0' [+2]
|
||||
" brne loop%=\n\t" // '1' [+3] '0' [+4]
|
||||
: "=&d" (ctr)
|
||||
: "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo)
|
||||
);
|
||||
}
|
||||
" dec %0 \n\t" // '1' [+2] '0' [+2]
|
||||
" brne loop%=\n\t" // '1' [+3] '0' [+4]
|
||||
: "=&d"(ctr)
|
||||
: "r"(curbyte), "I"(_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r"(maskhi), "r"(masklo));
|
||||
}
|
||||
|
||||
SREG=sreg_prev;
|
||||
SREG = sreg_prev;
|
||||
}
|
||||
|
@ -43,12 +43,12 @@
|
||||
* - Wait 50<EFBFBD>s to reset the LEDs
|
||||
*/
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
void ws2812_setled (int index, uint8_t r, uint8_t g, uint8_t b);
|
||||
void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b);
|
||||
void ws2812_setled(int index, uint8_t r, uint8_t g, uint8_t b);
|
||||
void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b);
|
||||
#endif
|
||||
|
||||
void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);
|
||||
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
|
||||
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
|
||||
/*
|
||||
@ -58,18 +58,17 @@ void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
* The length is the number of bytes to send - three per LED.
|
||||
*/
|
||||
|
||||
void ws2812_sendarray (uint8_t *array,uint16_t length);
|
||||
void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask);
|
||||
|
||||
void ws2812_sendarray(uint8_t *array, uint16_t length);
|
||||
void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask);
|
||||
|
||||
/*
|
||||
* Internal defines
|
||||
*/
|
||||
#ifndef CONCAT
|
||||
#define CONCAT(a, b) a ## b
|
||||
# define CONCAT(a, b) a##b
|
||||
#endif
|
||||
#ifndef CONCAT_EXP
|
||||
#define CONCAT_EXP(a, b) CONCAT(a, b)
|
||||
# define CONCAT_EXP(a, b) CONCAT(a, b)
|
||||
#endif
|
||||
|
||||
#endif /* LIGHT_WS2812_H_ */
|
||||
|
@ -23,42 +23,33 @@
|
||||
* This variable is used by the HAL when initializing the PAL driver.
|
||||
*/
|
||||
const PALConfig pal_default_config = {
|
||||
#if STM32_HAS_GPIOA
|
||||
{VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
|
||||
VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOB
|
||||
{VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
|
||||
VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOC
|
||||
{VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
|
||||
VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOD
|
||||
{VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
|
||||
VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOE
|
||||
{VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
|
||||
VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOF
|
||||
{VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
|
||||
VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOG
|
||||
{VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
|
||||
VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOH
|
||||
{VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
|
||||
VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOI
|
||||
{VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
|
||||
VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
|
||||
#endif
|
||||
# if STM32_HAS_GPIOA
|
||||
{VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOB
|
||||
{VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOC
|
||||
{VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOD
|
||||
{VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOE
|
||||
{VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOF
|
||||
{VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOG
|
||||
{VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOH
|
||||
{VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
|
||||
# endif
|
||||
# if STM32_HAS_GPIOI
|
||||
{VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
|
||||
# endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -70,8 +61,8 @@ void enter_bootloader_mode_if_requested(void);
|
||||
* and before any other initialization.
|
||||
*/
|
||||
void __early_init(void) {
|
||||
enter_bootloader_mode_if_requested();
|
||||
stm32_clock_init();
|
||||
enter_bootloader_mode_if_requested();
|
||||
stm32_clock_init();
|
||||
}
|
||||
|
||||
#if HAL_USE_SDC || defined(__DOXYGEN__)
|
||||
@ -79,20 +70,18 @@ void __early_init(void) {
|
||||
* @brief SDC card detection.
|
||||
*/
|
||||
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
|
||||
|
||||
(void)sdcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return true;
|
||||
(void)sdcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SDC card write protection detection.
|
||||
*/
|
||||
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
|
||||
|
||||
(void)sdcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return false;
|
||||
(void)sdcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return false;
|
||||
}
|
||||
#endif /* HAL_USE_SDC */
|
||||
|
||||
@ -101,20 +90,18 @@ bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
|
||||
* @brief MMC_SPI card detection.
|
||||
*/
|
||||
bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
|
||||
|
||||
(void)mmcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return true;
|
||||
(void)mmcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MMC_SPI card write protection detection.
|
||||
*/
|
||||
bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
|
||||
|
||||
(void)mmcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return false;
|
||||
(void)mmcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -122,5 +109,4 @@ bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
|
||||
* @brief Board-specific initialization code.
|
||||
* @todo Add your board-specific code, if any.
|
||||
*/
|
||||
void boardInit(void) {
|
||||
}
|
||||
void boardInit(void) {}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,154 +21,109 @@
|
||||
* @details Digital I/O ports static configuration as defined in @p board.h.
|
||||
* This variable is used by the HAL when initializing the PAL driver.
|
||||
*/
|
||||
const PALConfig pal_default_config =
|
||||
{
|
||||
.ports = {
|
||||
const PALConfig pal_default_config = {
|
||||
.ports =
|
||||
{
|
||||
/*
|
||||
* PORTA setup.
|
||||
*
|
||||
* PTA4 - PIN33
|
||||
* PTA5 - PIN24
|
||||
* PTA12 - PIN3
|
||||
* PTA13 - PIN4
|
||||
*
|
||||
* PTA18/19 crystal
|
||||
* PTA0/3 SWD
|
||||
*/
|
||||
.port = IOPORT1,
|
||||
.pads = {
|
||||
PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
{
|
||||
/*
|
||||
* PORTA setup.
|
||||
*
|
||||
* PTA4 - PIN33
|
||||
* PTA5 - PIN24
|
||||
* PTA12 - PIN3
|
||||
* PTA13 - PIN4
|
||||
*
|
||||
* PTA18/19 crystal
|
||||
* PTA0/3 SWD
|
||||
*/
|
||||
.port = IOPORT1,
|
||||
.pads =
|
||||
{
|
||||
PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTB setup.
|
||||
*
|
||||
* PTB0 - PIN16
|
||||
* PTB1 - PIN17
|
||||
* PTB2 - PIN19
|
||||
* PTB3 - PIN18
|
||||
* PTB16 - PIN0 - UART0_TX
|
||||
* PTB17 - PIN1 - UART0_RX
|
||||
* PTB18 - PIN32
|
||||
* PTB19 - PIN25
|
||||
*/
|
||||
.port = IOPORT2,
|
||||
.pads =
|
||||
{
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTC setup.
|
||||
*
|
||||
* PTC0 - PIN15
|
||||
* PTC1 - PIN22
|
||||
* PTC2 - PIN23
|
||||
* PTC3 - PIN9
|
||||
* PTC4 - PIN10
|
||||
* PTC5 - PIN13
|
||||
* PTC6 - PIN11
|
||||
* PTC7 - PIN12
|
||||
* PTC8 - PIN28
|
||||
* PTC9 - PIN27
|
||||
* PTC10 - PIN29
|
||||
* PTC11 - PIN30
|
||||
*/
|
||||
.port = IOPORT3,
|
||||
.pads =
|
||||
{
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTD setup.
|
||||
*
|
||||
* PTD0 - PIN2
|
||||
* PTD1 - PIN14
|
||||
* PTD2 - PIN7
|
||||
* PTD3 - PIN8
|
||||
* PTD4 - PIN6
|
||||
* PTD5 - PIN20
|
||||
* PTD6 - PIN21
|
||||
* PTD7 - PIN5
|
||||
*/
|
||||
.port = IOPORT4,
|
||||
.pads =
|
||||
{
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTE setup.
|
||||
*
|
||||
* PTE0 - PIN31
|
||||
* PTE1 - PIN26
|
||||
*/
|
||||
.port = IOPORT5,
|
||||
.pads =
|
||||
{
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTB setup.
|
||||
*
|
||||
* PTB0 - PIN16
|
||||
* PTB1 - PIN17
|
||||
* PTB2 - PIN19
|
||||
* PTB3 - PIN18
|
||||
* PTB16 - PIN0 - UART0_TX
|
||||
* PTB17 - PIN1 - UART0_RX
|
||||
* PTB18 - PIN32
|
||||
* PTB19 - PIN25
|
||||
*/
|
||||
.port = IOPORT2,
|
||||
.pads = {
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTC setup.
|
||||
*
|
||||
* PTC0 - PIN15
|
||||
* PTC1 - PIN22
|
||||
* PTC2 - PIN23
|
||||
* PTC3 - PIN9
|
||||
* PTC4 - PIN10
|
||||
* PTC5 - PIN13
|
||||
* PTC6 - PIN11
|
||||
* PTC7 - PIN12
|
||||
* PTC8 - PIN28
|
||||
* PTC9 - PIN27
|
||||
* PTC10 - PIN29
|
||||
* PTC11 - PIN30
|
||||
*/
|
||||
.port = IOPORT3,
|
||||
.pads = {
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTD setup.
|
||||
*
|
||||
* PTD0 - PIN2
|
||||
* PTD1 - PIN14
|
||||
* PTD2 - PIN7
|
||||
* PTD3 - PIN8
|
||||
* PTD4 - PIN6
|
||||
* PTD5 - PIN20
|
||||
* PTD6 - PIN21
|
||||
* PTD7 - PIN5
|
||||
*/
|
||||
.port = IOPORT4,
|
||||
.pads = {
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
{
|
||||
/*
|
||||
* PORTE setup.
|
||||
*
|
||||
* PTE0 - PIN31
|
||||
* PTE1 - PIN26
|
||||
*/
|
||||
.port = IOPORT5,
|
||||
.pads = {
|
||||
PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
#endif
|
||||
|
||||
// NOTE: This value comes from kiibohd/controller and is the location of a value
|
||||
// which needs to be checked before disabling the watchdog (which happens in
|
||||
// k20x_clock_init)
|
||||
#define WDOG_TMROUTL *(volatile uint16_t *)0x40052012
|
||||
#define WDOG_TMROUTL *(volatile uint16_t *)0x40052012
|
||||
|
||||
/**
|
||||
* @brief Early initialization code.
|
||||
@ -176,16 +131,16 @@ const PALConfig pal_default_config =
|
||||
* and before any other initialization.
|
||||
*/
|
||||
void __early_init(void) {
|
||||
// This is a dirty hack and should only be used as a temporary fix until this
|
||||
// is upstreamed.
|
||||
while (WDOG_TMROUTL < 2); // Must wait for WDOG timer if already running, before jumping
|
||||
// This is a dirty hack and should only be used as a temporary fix until this
|
||||
// is upstreamed.
|
||||
while (WDOG_TMROUTL < 2)
|
||||
; // Must wait for WDOG timer if already running, before jumping
|
||||
|
||||
k20x_clock_init();
|
||||
k20x_clock_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Board-specific initialization code.
|
||||
* @todo Add your board-specific code, if any.
|
||||
*/
|
||||
void boardInit(void) {
|
||||
}
|
||||
void boardInit(void) {}
|
||||
|
@ -25,13 +25,13 @@
|
||||
* Board identifier.
|
||||
*/
|
||||
#define BOARD_PJRC_TEENSY_3_1
|
||||
#define BOARD_NAME "PJRC Teensy 3.1"
|
||||
#define BOARD_NAME "PJRC Teensy 3.1"
|
||||
|
||||
/* External 16 MHz crystal */
|
||||
#define KINETIS_XTAL_FREQUENCY 16000000UL
|
||||
#define KINETIS_XTAL_FREQUENCY 16000000UL
|
||||
|
||||
/* Use internal capacitors for the crystal */
|
||||
#define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P|OSC_CR_SC2P
|
||||
#define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P | OSC_CR_SC2P
|
||||
|
||||
/*
|
||||
* MCU type
|
||||
@ -41,79 +41,79 @@
|
||||
/*
|
||||
* IO pins assignments.
|
||||
*/
|
||||
#define PORTA_PIN0 0
|
||||
#define PORTA_PIN1 1
|
||||
#define PORTA_PIN2 2
|
||||
#define PORTA_PIN3 3
|
||||
#define TEENSY_PIN33 4
|
||||
#define TEENSY_PIN24 5
|
||||
#define PORTA_PIN6 6
|
||||
#define PORTA_PIN7 7
|
||||
#define PORTA_PIN8 8
|
||||
#define PORTA_PIN9 9
|
||||
#define PORTA_PIN10 10
|
||||
#define PORTA_PIN11 11
|
||||
#define TEENSY_PIN3 12
|
||||
#define TEENSY_PIN4 13
|
||||
#define PORTA_PIN14 14
|
||||
#define PORTA_PIN15 15
|
||||
#define PORTA_PIN16 16
|
||||
#define PORTA_PIN17 17
|
||||
#define PORTA_PIN18 18
|
||||
#define PORTA_PIN19 19
|
||||
#define PORTA_PIN20 20
|
||||
#define PORTA_PIN21 21
|
||||
#define PORTA_PIN22 22
|
||||
#define PORTA_PIN23 23
|
||||
#define PORTA_PIN24 24
|
||||
#define PORTA_PIN25 25
|
||||
#define PORTA_PIN26 26
|
||||
#define PORTA_PIN27 27
|
||||
#define PORTA_PIN28 28
|
||||
#define PORTA_PIN29 29
|
||||
#define PORTA_PIN30 30
|
||||
#define PORTA_PIN31 31
|
||||
#define PORTA_PIN0 0
|
||||
#define PORTA_PIN1 1
|
||||
#define PORTA_PIN2 2
|
||||
#define PORTA_PIN3 3
|
||||
#define TEENSY_PIN33 4
|
||||
#define TEENSY_PIN24 5
|
||||
#define PORTA_PIN6 6
|
||||
#define PORTA_PIN7 7
|
||||
#define PORTA_PIN8 8
|
||||
#define PORTA_PIN9 9
|
||||
#define PORTA_PIN10 10
|
||||
#define PORTA_PIN11 11
|
||||
#define TEENSY_PIN3 12
|
||||
#define TEENSY_PIN4 13
|
||||
#define PORTA_PIN14 14
|
||||
#define PORTA_PIN15 15
|
||||
#define PORTA_PIN16 16
|
||||
#define PORTA_PIN17 17
|
||||
#define PORTA_PIN18 18
|
||||
#define PORTA_PIN19 19
|
||||
#define PORTA_PIN20 20
|
||||
#define PORTA_PIN21 21
|
||||
#define PORTA_PIN22 22
|
||||
#define PORTA_PIN23 23
|
||||
#define PORTA_PIN24 24
|
||||
#define PORTA_PIN25 25
|
||||
#define PORTA_PIN26 26
|
||||
#define PORTA_PIN27 27
|
||||
#define PORTA_PIN28 28
|
||||
#define PORTA_PIN29 29
|
||||
#define PORTA_PIN30 30
|
||||
#define PORTA_PIN31 31
|
||||
|
||||
#define TEENSY_PIN3_IOPORT IOPORT1
|
||||
#define TEENSY_PIN4_IOPORT IOPORT1
|
||||
#define TEENSY_PIN3_IOPORT IOPORT1
|
||||
#define TEENSY_PIN4_IOPORT IOPORT1
|
||||
#define TEENSY_PIN24_IOPORT IOPORT1
|
||||
#define TEENSY_PIN33_IOPORT IOPORT1
|
||||
|
||||
#define TEENSY_PIN16 0
|
||||
#define TEENSY_PIN17 1
|
||||
#define TEENSY_PIN19 2
|
||||
#define TEENSY_PIN18 3
|
||||
#define PORTB_PIN4 4
|
||||
#define PORTB_PIN5 5
|
||||
#define PORTB_PIN6 6
|
||||
#define PORTB_PIN7 7
|
||||
#define PORTB_PIN8 8
|
||||
#define PORTB_PIN9 9
|
||||
#define PORTB_PIN10 10
|
||||
#define PORTB_PIN11 11
|
||||
#define PORTB_PIN12 12
|
||||
#define PORTB_PIN13 13
|
||||
#define PORTB_PIN14 14
|
||||
#define PORTB_PIN15 15
|
||||
#define TEENSY_PIN0 16
|
||||
#define TEENSY_PIN1 17
|
||||
#define TEENSY_PIN32 18
|
||||
#define TEENSY_PIN25 19
|
||||
#define PORTB_PIN20 20
|
||||
#define PORTB_PIN21 21
|
||||
#define PORTB_PIN22 22
|
||||
#define PORTB_PIN23 23
|
||||
#define PORTB_PIN24 24
|
||||
#define PORTB_PIN25 25
|
||||
#define PORTB_PIN26 26
|
||||
#define PORTB_PIN27 27
|
||||
#define PORTB_PIN28 28
|
||||
#define PORTB_PIN29 29
|
||||
#define PORTB_PIN30 30
|
||||
#define PORTB_PIN31 31
|
||||
#define TEENSY_PIN16 0
|
||||
#define TEENSY_PIN17 1
|
||||
#define TEENSY_PIN19 2
|
||||
#define TEENSY_PIN18 3
|
||||
#define PORTB_PIN4 4
|
||||
#define PORTB_PIN5 5
|
||||
#define PORTB_PIN6 6
|
||||
#define PORTB_PIN7 7
|
||||
#define PORTB_PIN8 8
|
||||
#define PORTB_PIN9 9
|
||||
#define PORTB_PIN10 10
|
||||
#define PORTB_PIN11 11
|
||||
#define PORTB_PIN12 12
|
||||
#define PORTB_PIN13 13
|
||||
#define PORTB_PIN14 14
|
||||
#define PORTB_PIN15 15
|
||||
#define TEENSY_PIN0 16
|
||||
#define TEENSY_PIN1 17
|
||||
#define TEENSY_PIN32 18
|
||||
#define TEENSY_PIN25 19
|
||||
#define PORTB_PIN20 20
|
||||
#define PORTB_PIN21 21
|
||||
#define PORTB_PIN22 22
|
||||
#define PORTB_PIN23 23
|
||||
#define PORTB_PIN24 24
|
||||
#define PORTB_PIN25 25
|
||||
#define PORTB_PIN26 26
|
||||
#define PORTB_PIN27 27
|
||||
#define PORTB_PIN28 28
|
||||
#define PORTB_PIN29 29
|
||||
#define PORTB_PIN30 30
|
||||
#define PORTB_PIN31 31
|
||||
|
||||
#define TEENSY_PIN0_IOPORT IOPORT2
|
||||
#define TEENSY_PIN1_IOPORT IOPORT2
|
||||
#define TEENSY_PIN0_IOPORT IOPORT2
|
||||
#define TEENSY_PIN1_IOPORT IOPORT2
|
||||
#define TEENSY_PIN16_IOPORT IOPORT2
|
||||
#define TEENSY_PIN17_IOPORT IOPORT2
|
||||
#define TEENSY_PIN18_IOPORT IOPORT2
|
||||
@ -121,40 +121,40 @@
|
||||
#define TEENSY_PIN25_IOPORT IOPORT2
|
||||
#define TEENSY_PIN32_IOPORT IOPORT2
|
||||
|
||||
#define TEENSY_PIN15 0
|
||||
#define TEENSY_PIN22 1
|
||||
#define TEENSY_PIN23 2
|
||||
#define TEENSY_PIN9 3
|
||||
#define TEENSY_PIN10 4
|
||||
#define TEENSY_PIN13 5
|
||||
#define TEENSY_PIN11 6
|
||||
#define TEENSY_PIN12 7
|
||||
#define TEENSY_PIN28 8
|
||||
#define TEENSY_PIN27 9
|
||||
#define TEENSY_PIN29 10
|
||||
#define TEENSY_PIN30 11
|
||||
#define PORTC_PIN12 12
|
||||
#define PORTC_PIN13 13
|
||||
#define PORTC_PIN14 14
|
||||
#define PORTC_PIN15 15
|
||||
#define PORTC_PIN16 16
|
||||
#define PORTC_PIN17 17
|
||||
#define PORTC_PIN18 18
|
||||
#define PORTC_PIN19 19
|
||||
#define PORTC_PIN20 20
|
||||
#define PORTC_PIN21 21
|
||||
#define PORTC_PIN22 22
|
||||
#define PORTC_PIN23 23
|
||||
#define PORTC_PIN24 24
|
||||
#define PORTC_PIN25 25
|
||||
#define PORTC_PIN26 26
|
||||
#define PORTC_PIN27 27
|
||||
#define PORTC_PIN28 28
|
||||
#define PORTC_PIN29 29
|
||||
#define PORTC_PIN30 30
|
||||
#define PORTC_PIN31 31
|
||||
#define TEENSY_PIN15 0
|
||||
#define TEENSY_PIN22 1
|
||||
#define TEENSY_PIN23 2
|
||||
#define TEENSY_PIN9 3
|
||||
#define TEENSY_PIN10 4
|
||||
#define TEENSY_PIN13 5
|
||||
#define TEENSY_PIN11 6
|
||||
#define TEENSY_PIN12 7
|
||||
#define TEENSY_PIN28 8
|
||||
#define TEENSY_PIN27 9
|
||||
#define TEENSY_PIN29 10
|
||||
#define TEENSY_PIN30 11
|
||||
#define PORTC_PIN12 12
|
||||
#define PORTC_PIN13 13
|
||||
#define PORTC_PIN14 14
|
||||
#define PORTC_PIN15 15
|
||||
#define PORTC_PIN16 16
|
||||
#define PORTC_PIN17 17
|
||||
#define PORTC_PIN18 18
|
||||
#define PORTC_PIN19 19
|
||||
#define PORTC_PIN20 20
|
||||
#define PORTC_PIN21 21
|
||||
#define PORTC_PIN22 22
|
||||
#define PORTC_PIN23 23
|
||||
#define PORTC_PIN24 24
|
||||
#define PORTC_PIN25 25
|
||||
#define PORTC_PIN26 26
|
||||
#define PORTC_PIN27 27
|
||||
#define PORTC_PIN28 28
|
||||
#define PORTC_PIN29 29
|
||||
#define PORTC_PIN30 30
|
||||
#define PORTC_PIN31 31
|
||||
|
||||
#define TEENSY_PIN9_IOPORT IOPORT3
|
||||
#define TEENSY_PIN9_IOPORT IOPORT3
|
||||
#define TEENSY_PIN10_IOPORT IOPORT3
|
||||
#define TEENSY_PIN11_IOPORT IOPORT3
|
||||
#define TEENSY_PIN12_IOPORT IOPORT3
|
||||
@ -167,129 +167,129 @@
|
||||
#define TEENSY_PIN29_IOPORT IOPORT3
|
||||
#define TEENSY_PIN30_IOPORT IOPORT3
|
||||
|
||||
#define TEENSY_PIN2 0
|
||||
#define TEENSY_PIN14 1
|
||||
#define TEENSY_PIN7 2
|
||||
#define TEENSY_PIN8 3
|
||||
#define TEENSY_PIN6 4
|
||||
#define TEENSY_PIN20 5
|
||||
#define TEENSY_PIN21 6
|
||||
#define TEENSY_PIN5 7
|
||||
#define PORTD_PIN8 8
|
||||
#define PORTD_PIN9 9
|
||||
#define PORTD_PIN10 10
|
||||
#define PORTD_PIN11 11
|
||||
#define PORTD_PIN12 12
|
||||
#define PORTD_PIN13 13
|
||||
#define PORTD_PIN14 14
|
||||
#define PORTD_PIN15 15
|
||||
#define PORTD_PIN16 16
|
||||
#define PORTD_PIN17 17
|
||||
#define PORTD_PIN18 18
|
||||
#define PORTD_PIN19 19
|
||||
#define PORTD_PIN20 20
|
||||
#define PORTD_PIN21 21
|
||||
#define PORTD_PIN22 22
|
||||
#define PORTD_PIN23 23
|
||||
#define PORTD_PIN24 24
|
||||
#define PORTD_PIN25 25
|
||||
#define PORTD_PIN26 26
|
||||
#define PORTD_PIN27 27
|
||||
#define PORTD_PIN28 28
|
||||
#define PORTD_PIN29 29
|
||||
#define PORTD_PIN30 30
|
||||
#define PORTD_PIN31 31
|
||||
#define TEENSY_PIN2 0
|
||||
#define TEENSY_PIN14 1
|
||||
#define TEENSY_PIN7 2
|
||||
#define TEENSY_PIN8 3
|
||||
#define TEENSY_PIN6 4
|
||||
#define TEENSY_PIN20 5
|
||||
#define TEENSY_PIN21 6
|
||||
#define TEENSY_PIN5 7
|
||||
#define PORTD_PIN8 8
|
||||
#define PORTD_PIN9 9
|
||||
#define PORTD_PIN10 10
|
||||
#define PORTD_PIN11 11
|
||||
#define PORTD_PIN12 12
|
||||
#define PORTD_PIN13 13
|
||||
#define PORTD_PIN14 14
|
||||
#define PORTD_PIN15 15
|
||||
#define PORTD_PIN16 16
|
||||
#define PORTD_PIN17 17
|
||||
#define PORTD_PIN18 18
|
||||
#define PORTD_PIN19 19
|
||||
#define PORTD_PIN20 20
|
||||
#define PORTD_PIN21 21
|
||||
#define PORTD_PIN22 22
|
||||
#define PORTD_PIN23 23
|
||||
#define PORTD_PIN24 24
|
||||
#define PORTD_PIN25 25
|
||||
#define PORTD_PIN26 26
|
||||
#define PORTD_PIN27 27
|
||||
#define PORTD_PIN28 28
|
||||
#define PORTD_PIN29 29
|
||||
#define PORTD_PIN30 30
|
||||
#define PORTD_PIN31 31
|
||||
|
||||
#define TEENSY_PIN2_IOPORT IOPORT4
|
||||
#define TEENSY_PIN5_IOPORT IOPORT4
|
||||
#define TEENSY_PIN6_IOPORT IOPORT4
|
||||
#define TEENSY_PIN7_IOPORT IOPORT4
|
||||
#define TEENSY_PIN8_IOPORT IOPORT4
|
||||
#define TEENSY_PIN2_IOPORT IOPORT4
|
||||
#define TEENSY_PIN5_IOPORT IOPORT4
|
||||
#define TEENSY_PIN6_IOPORT IOPORT4
|
||||
#define TEENSY_PIN7_IOPORT IOPORT4
|
||||
#define TEENSY_PIN8_IOPORT IOPORT4
|
||||
#define TEENSY_PIN14_IOPORT IOPORT4
|
||||
#define TEENSY_PIN20_IOPORT IOPORT4
|
||||
#define TEENSY_PIN21_IOPORT IOPORT4
|
||||
|
||||
#define TEENSY_PIN31 0
|
||||
#define TEENSY_PIN26 1
|
||||
#define PORTE_PIN2 2
|
||||
#define PORTE_PIN3 3
|
||||
#define PORTE_PIN4 4
|
||||
#define PORTE_PIN5 5
|
||||
#define PORTE_PIN6 6
|
||||
#define PORTE_PIN7 7
|
||||
#define PORTE_PIN8 8
|
||||
#define PORTE_PIN9 9
|
||||
#define PORTE_PIN10 10
|
||||
#define PORTE_PIN11 11
|
||||
#define PORTE_PIN12 12
|
||||
#define PORTE_PIN13 13
|
||||
#define PORTE_PIN14 14
|
||||
#define PORTE_PIN15 15
|
||||
#define PORTE_PIN16 16
|
||||
#define PORTE_PIN17 17
|
||||
#define PORTE_PIN18 18
|
||||
#define PORTE_PIN19 19
|
||||
#define PORTE_PIN20 20
|
||||
#define PORTE_PIN21 21
|
||||
#define PORTE_PIN22 22
|
||||
#define PORTE_PIN23 23
|
||||
#define PORTE_PIN24 24
|
||||
#define PORTE_PIN25 25
|
||||
#define PORTE_PIN26 26
|
||||
#define PORTE_PIN27 27
|
||||
#define PORTE_PIN28 28
|
||||
#define PORTE_PIN29 29
|
||||
#define PORTE_PIN30 30
|
||||
#define PORTE_PIN31 31
|
||||
#define TEENSY_PIN31 0
|
||||
#define TEENSY_PIN26 1
|
||||
#define PORTE_PIN2 2
|
||||
#define PORTE_PIN3 3
|
||||
#define PORTE_PIN4 4
|
||||
#define PORTE_PIN5 5
|
||||
#define PORTE_PIN6 6
|
||||
#define PORTE_PIN7 7
|
||||
#define PORTE_PIN8 8
|
||||
#define PORTE_PIN9 9
|
||||
#define PORTE_PIN10 10
|
||||
#define PORTE_PIN11 11
|
||||
#define PORTE_PIN12 12
|
||||
#define PORTE_PIN13 13
|
||||
#define PORTE_PIN14 14
|
||||
#define PORTE_PIN15 15
|
||||
#define PORTE_PIN16 16
|
||||
#define PORTE_PIN17 17
|
||||
#define PORTE_PIN18 18
|
||||
#define PORTE_PIN19 19
|
||||
#define PORTE_PIN20 20
|
||||
#define PORTE_PIN21 21
|
||||
#define PORTE_PIN22 22
|
||||
#define PORTE_PIN23 23
|
||||
#define PORTE_PIN24 24
|
||||
#define PORTE_PIN25 25
|
||||
#define PORTE_PIN26 26
|
||||
#define PORTE_PIN27 27
|
||||
#define PORTE_PIN28 28
|
||||
#define PORTE_PIN29 29
|
||||
#define PORTE_PIN30 30
|
||||
#define PORTE_PIN31 31
|
||||
|
||||
#define TEENSY_PIN26_IOPORT IOPORT5
|
||||
#define TEENSY_PIN31_IOPORT IOPORT5
|
||||
|
||||
#define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1)
|
||||
#define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2)
|
||||
#define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3)
|
||||
#define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4)
|
||||
#define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5)
|
||||
#define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6)
|
||||
#define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7)
|
||||
#define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8)
|
||||
#define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9)
|
||||
#define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10)
|
||||
#define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11)
|
||||
#define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12)
|
||||
#define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13)
|
||||
#define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14)
|
||||
#define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15)
|
||||
#define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16)
|
||||
#define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17)
|
||||
#define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18)
|
||||
#define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19)
|
||||
#define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20)
|
||||
#define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21)
|
||||
#define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22)
|
||||
#define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23)
|
||||
#define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24)
|
||||
#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
|
||||
#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
|
||||
#define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26)
|
||||
#define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27)
|
||||
#define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28)
|
||||
#define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29)
|
||||
#define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30)
|
||||
#define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31)
|
||||
#define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32)
|
||||
#define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33)
|
||||
#define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1)
|
||||
#define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2)
|
||||
#define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3)
|
||||
#define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4)
|
||||
#define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5)
|
||||
#define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6)
|
||||
#define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7)
|
||||
#define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8)
|
||||
#define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9)
|
||||
#define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10)
|
||||
#define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11)
|
||||
#define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12)
|
||||
#define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13)
|
||||
#define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14)
|
||||
#define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15)
|
||||
#define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16)
|
||||
#define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17)
|
||||
#define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18)
|
||||
#define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19)
|
||||
#define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20)
|
||||
#define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21)
|
||||
#define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22)
|
||||
#define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23)
|
||||
#define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24)
|
||||
#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
|
||||
#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
|
||||
#define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26)
|
||||
#define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27)
|
||||
#define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28)
|
||||
#define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29)
|
||||
#define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30)
|
||||
#define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31)
|
||||
#define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32)
|
||||
#define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33)
|
||||
|
||||
#define LINE_LED LINE_PIN13
|
||||
#define LINE_LED LINE_PIN13
|
||||
|
||||
#if !defined(_FROM_ASM_)
|
||||
#ifdef __cplusplus
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void boardInit(void);
|
||||
#ifdef __cplusplus
|
||||
# endif
|
||||
void boardInit(void);
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
#endif /* _FROM_ASM_ */
|
||||
|
||||
#endif /* _BOARD_H_ */
|
||||
|
78
drivers/gpio/pca9555.c
Normal file
78
drivers/gpio/pca9555.c
Normal file
@ -0,0 +1,78 @@
|
||||
/* Copyright 2019
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "i2c_master.h"
|
||||
#include "pca9555.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#define SLAVE_TO_ADDR(n) (n << 1)
|
||||
#define TIMEOUT 100
|
||||
|
||||
enum {
|
||||
CMD_INPUT_0 = 0,
|
||||
CMD_INPUT_1,
|
||||
CMD_OUTPUT_0,
|
||||
CMD_OUTPUT_1,
|
||||
CMD_INVERSION_0,
|
||||
CMD_INVERSION_1,
|
||||
CMD_CONFIG_0,
|
||||
CMD_CONFIG_1,
|
||||
};
|
||||
|
||||
void pca9555_init(uint8_t slave_addr) {
|
||||
static uint8_t s_init = 0;
|
||||
if (!s_init) {
|
||||
i2c_init();
|
||||
|
||||
s_init = 1;
|
||||
}
|
||||
|
||||
// TODO: could check device connected
|
||||
// i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
|
||||
// i2c_stop();
|
||||
}
|
||||
|
||||
void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_set_config::FAILED\n");
|
||||
}
|
||||
}
|
||||
|
||||
void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_set_output::FAILED\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0;
|
||||
|
||||
uint8_t data = 0;
|
||||
i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_readPins::FAILED\n");
|
||||
}
|
||||
return data;
|
||||
}
|
@ -20,110 +20,102 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
uint8_t DRV2605L_transfer_buffer[2];
|
||||
uint8_t DRV2605L_tx_register[0];
|
||||
uint8_t DRV2605L_read_buffer[0];
|
||||
uint8_t DRV2605L_read_register;
|
||||
|
||||
|
||||
void DRV_write(uint8_t drv_register, uint8_t settings) {
|
||||
DRV2605L_transfer_buffer[0] = drv_register;
|
||||
DRV2605L_transfer_buffer[1] = settings;
|
||||
i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100);
|
||||
DRV2605L_transfer_buffer[0] = drv_register;
|
||||
DRV2605L_transfer_buffer[1] = settings;
|
||||
i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100);
|
||||
}
|
||||
|
||||
uint8_t DRV_read(uint8_t regaddress) {
|
||||
#ifdef __AVR__
|
||||
i2c_readReg(DRV2605L_BASE_ADDRESS << 1,
|
||||
regaddress, DRV2605L_read_buffer, 1, 100);
|
||||
DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
|
||||
i2c_readReg(DRV2605L_BASE_ADDRESS << 1, regaddress, DRV2605L_read_buffer, 1, 100);
|
||||
DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
|
||||
#else
|
||||
DRV2605L_tx_register[0] = regaddress;
|
||||
if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1,
|
||||
DRV2605L_tx_register, 1,
|
||||
DRV2605L_read_buffer, 1
|
||||
)){
|
||||
printf("err reading reg \n");
|
||||
}
|
||||
DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
|
||||
DRV2605L_tx_register[0] = regaddress;
|
||||
if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1, DRV2605L_tx_register, 1, DRV2605L_read_buffer, 1)) {
|
||||
printf("err reading reg \n");
|
||||
}
|
||||
DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
|
||||
#endif
|
||||
return DRV2605L_read_register;
|
||||
return DRV2605L_read_register;
|
||||
}
|
||||
|
||||
void DRV_init(void)
|
||||
{
|
||||
i2c_init();
|
||||
/* 0x07 sets DRV2605 into calibration mode */
|
||||
DRV_write(DRV_MODE,0x07);
|
||||
void DRV_init(void) {
|
||||
i2c_init();
|
||||
/* 0x07 sets DRV2605 into calibration mode */
|
||||
DRV_write(DRV_MODE, 0x07);
|
||||
|
||||
// DRV_write(DRV_FEEDBACK_CTRL,0xB6);
|
||||
|
||||
#if FB_ERM_LRA == 0
|
||||
// DRV_write(DRV_FEEDBACK_CTRL,0xB6);
|
||||
|
||||
#if FB_ERM_LRA == 0
|
||||
/* ERM settings */
|
||||
DRV_write(DRV_RATED_VOLT, (RATED_VOLTAGE/21.33)*1000);
|
||||
#if ERM_OPEN_LOOP == 0
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (((V_PEAK*(DRIVE_TIME+BLANKING_TIME+IDISS_TIME))/0.02133)/(DRIVE_TIME-0.0003)));
|
||||
#elif ERM_OPEN_LOOP == 1
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK/0.02196));
|
||||
#endif
|
||||
#elif FB_ERM_LRA == 1
|
||||
DRV_write(DRV_RATED_VOLT, ((V_RMS * sqrt(1 - ((4 * ((150+(SAMPLE_TIME*50))*0.000001)) + 0.0003)* F_LRA)/0.02071)));
|
||||
#if LRA_OPEN_LOOP == 0
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, ((V_PEAK/sqrt(1-(F_LRA*0.0008))/0.02133)));
|
||||
#elif LRA_OPEN_LOOP == 1
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK/0.02196));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DRVREG_FBR FB_SET;
|
||||
FB_SET.Bits.ERM_LRA = FB_ERM_LRA;
|
||||
DRV_write(DRV_RATED_VOLT, (RATED_VOLTAGE / 21.33) * 1000);
|
||||
# if ERM_OPEN_LOOP == 0
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (((V_PEAK * (DRIVE_TIME + BLANKING_TIME + IDISS_TIME)) / 0.02133) / (DRIVE_TIME - 0.0003)));
|
||||
# elif ERM_OPEN_LOOP == 1
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK / 0.02196));
|
||||
# endif
|
||||
#elif FB_ERM_LRA == 1
|
||||
DRV_write(DRV_RATED_VOLT, ((V_RMS * sqrt(1 - ((4 * ((150 + (SAMPLE_TIME * 50)) * 0.000001)) + 0.0003) * F_LRA) / 0.02071)));
|
||||
# if LRA_OPEN_LOOP == 0
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, ((V_PEAK / sqrt(1 - (F_LRA * 0.0008)) / 0.02133)));
|
||||
# elif LRA_OPEN_LOOP == 1
|
||||
DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK / 0.02196));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
DRVREG_FBR FB_SET;
|
||||
FB_SET.Bits.ERM_LRA = FB_ERM_LRA;
|
||||
FB_SET.Bits.BRAKE_FACTOR = FB_BRAKEFACTOR;
|
||||
FB_SET.Bits.LOOP_GAIN =FB_LOOPGAIN;
|
||||
FB_SET.Bits.BEMF_GAIN = 0; /* auto-calibration populates this field*/
|
||||
DRV_write(DRV_FEEDBACK_CTRL, (uint8_t) FB_SET.Byte);
|
||||
DRVREG_CTRL1 C1_SET;
|
||||
C1_SET.Bits.C1_DRIVE_TIME = DRIVE_TIME;
|
||||
C1_SET.Bits.C1_AC_COUPLE = AC_COUPLE;
|
||||
FB_SET.Bits.LOOP_GAIN = FB_LOOPGAIN;
|
||||
FB_SET.Bits.BEMF_GAIN = 0; /* auto-calibration populates this field*/
|
||||
DRV_write(DRV_FEEDBACK_CTRL, (uint8_t)FB_SET.Byte);
|
||||
DRVREG_CTRL1 C1_SET;
|
||||
C1_SET.Bits.C1_DRIVE_TIME = DRIVE_TIME;
|
||||
C1_SET.Bits.C1_AC_COUPLE = AC_COUPLE;
|
||||
C1_SET.Bits.C1_STARTUP_BOOST = STARTUP_BOOST;
|
||||
DRV_write(DRV_CTRL_1, (uint8_t) C1_SET.Byte);
|
||||
DRVREG_CTRL2 C2_SET;
|
||||
C2_SET.Bits.C2_BIDIR_INPUT = BIDIR_INPUT;
|
||||
C2_SET.Bits.C2_BRAKE_STAB = BRAKE_STAB;
|
||||
C2_SET.Bits.C2_SAMPLE_TIME = SAMPLE_TIME;
|
||||
DRV_write(DRV_CTRL_1, (uint8_t)C1_SET.Byte);
|
||||
DRVREG_CTRL2 C2_SET;
|
||||
C2_SET.Bits.C2_BIDIR_INPUT = BIDIR_INPUT;
|
||||
C2_SET.Bits.C2_BRAKE_STAB = BRAKE_STAB;
|
||||
C2_SET.Bits.C2_SAMPLE_TIME = SAMPLE_TIME;
|
||||
C2_SET.Bits.C2_BLANKING_TIME = BLANKING_TIME;
|
||||
C2_SET.Bits.C2_IDISS_TIME = IDISS_TIME;
|
||||
DRV_write(DRV_CTRL_2, (uint8_t) C2_SET.Byte);
|
||||
DRVREG_CTRL3 C3_SET;
|
||||
C3_SET.Bits.C3_LRA_OPEN_LOOP = LRA_OPEN_LOOP;
|
||||
C3_SET.Bits.C3_N_PWM_ANALOG = N_PWM_ANALOG;
|
||||
C3_SET.Bits.C3_LRA_DRIVE_MODE = LRA_DRIVE_MODE;
|
||||
C2_SET.Bits.C2_IDISS_TIME = IDISS_TIME;
|
||||
DRV_write(DRV_CTRL_2, (uint8_t)C2_SET.Byte);
|
||||
DRVREG_CTRL3 C3_SET;
|
||||
C3_SET.Bits.C3_LRA_OPEN_LOOP = LRA_OPEN_LOOP;
|
||||
C3_SET.Bits.C3_N_PWM_ANALOG = N_PWM_ANALOG;
|
||||
C3_SET.Bits.C3_LRA_DRIVE_MODE = LRA_DRIVE_MODE;
|
||||
C3_SET.Bits.C3_DATA_FORMAT_RTO = DATA_FORMAT_RTO;
|
||||
C3_SET.Bits.C3_SUPPLY_COMP_DIS = SUPPLY_COMP_DIS;
|
||||
C3_SET.Bits.C3_ERM_OPEN_LOOP = ERM_OPEN_LOOP;
|
||||
C3_SET.Bits.C3_NG_THRESH = NG_THRESH;
|
||||
DRV_write(DRV_CTRL_3, (uint8_t) C3_SET.Byte);
|
||||
DRVREG_CTRL4 C4_SET;
|
||||
C4_SET.Bits.C4_ZC_DET_TIME = ZC_DET_TIME;
|
||||
C3_SET.Bits.C3_ERM_OPEN_LOOP = ERM_OPEN_LOOP;
|
||||
C3_SET.Bits.C3_NG_THRESH = NG_THRESH;
|
||||
DRV_write(DRV_CTRL_3, (uint8_t)C3_SET.Byte);
|
||||
DRVREG_CTRL4 C4_SET;
|
||||
C4_SET.Bits.C4_ZC_DET_TIME = ZC_DET_TIME;
|
||||
C4_SET.Bits.C4_AUTO_CAL_TIME = AUTO_CAL_TIME;
|
||||
DRV_write(DRV_CTRL_4, (uint8_t) C4_SET.Byte);
|
||||
DRV_write(DRV_LIB_SELECTION,LIB_SELECTION);
|
||||
DRV_write(DRV_CTRL_4, (uint8_t)C4_SET.Byte);
|
||||
DRV_write(DRV_LIB_SELECTION, LIB_SELECTION);
|
||||
|
||||
DRV_write(DRV_GO, 0x01);
|
||||
DRV_write(DRV_GO, 0x01);
|
||||
|
||||
/* 0x00 sets DRV2605 out of standby and to use internal trigger
|
||||
* 0x01 sets DRV2605 out of standby and to use external trigger */
|
||||
DRV_write(DRV_MODE,0x00);
|
||||
/* 0x00 sets DRV2605 out of standby and to use internal trigger
|
||||
* 0x01 sets DRV2605 out of standby and to use external trigger */
|
||||
DRV_write(DRV_MODE, 0x00);
|
||||
|
||||
//Play greeting sequence
|
||||
DRV_write(DRV_GO, 0x00);
|
||||
DRV_write(DRV_WAVEFORM_SEQ_1, DRV_GREETING);
|
||||
DRV_write(DRV_GO, 0x01);
|
||||
// Play greeting sequence
|
||||
DRV_write(DRV_GO, 0x00);
|
||||
DRV_write(DRV_WAVEFORM_SEQ_1, DRV_GREETING);
|
||||
DRV_write(DRV_GO, 0x01);
|
||||
}
|
||||
|
||||
void DRV_pulse(uint8_t sequence)
|
||||
{
|
||||
DRV_write(DRV_GO, 0x00);
|
||||
DRV_write(DRV_WAVEFORM_SEQ_1, sequence);
|
||||
DRV_write(DRV_GO, 0x01);
|
||||
void DRV_pulse(uint8_t sequence) {
|
||||
DRV_write(DRV_GO, 0x00);
|
||||
DRV_write(DRV_WAVEFORM_SEQ_1, sequence);
|
||||
DRV_write(DRV_GO, 0x01);
|
||||
}
|
@ -22,383 +22,383 @@
|
||||
|
||||
* Feedback Control Settings */
|
||||
#ifndef FB_ERM_LRA
|
||||
#define FB_ERM_LRA 1 /* For ERM:0 or LRA:1*/
|
||||
# define FB_ERM_LRA 1 /* For ERM:0 or LRA:1*/
|
||||
#endif
|
||||
#ifndef FB_BRAKEFACTOR
|
||||
#define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
|
||||
# define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
|
||||
#endif
|
||||
#ifndef FB_LOOPGAIN
|
||||
#define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
|
||||
# define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
|
||||
#endif
|
||||
|
||||
/* LRA specific settings */
|
||||
#if FB_ERM_LRA == 1
|
||||
#ifndef V_RMS
|
||||
#define V_RMS 2.0
|
||||
#endif
|
||||
#ifndef V_PEAK
|
||||
#define V_PEAK 2.1
|
||||
#endif
|
||||
#ifndef F_LRA
|
||||
#define F_LRA 205
|
||||
#endif
|
||||
#ifndef RATED_VOLTAGE
|
||||
#define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
|
||||
#endif
|
||||
# ifndef V_RMS
|
||||
# define V_RMS 2.0
|
||||
# endif
|
||||
# ifndef V_PEAK
|
||||
# define V_PEAK 2.1
|
||||
# endif
|
||||
# ifndef F_LRA
|
||||
# define F_LRA 205
|
||||
# endif
|
||||
# ifndef RATED_VOLTAGE
|
||||
# define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef RATED_VOLTAGE
|
||||
#define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
|
||||
# define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
|
||||
#endif
|
||||
#ifndef V_PEAK
|
||||
#define V_PEAK 2.8
|
||||
# define V_PEAK 2.8
|
||||
#endif
|
||||
|
||||
/* Library Selection */
|
||||
#ifndef LIB_SELECTION
|
||||
#if FB_ERM_LRA == 1
|
||||
#define LIB_SELECTION 6 /* For Empty:0' TS2200 library A to D:1-5, LRA Library: 6 */
|
||||
#else
|
||||
#define LIB_SELECTION 1
|
||||
#endif
|
||||
# if FB_ERM_LRA == 1
|
||||
# define LIB_SELECTION 6 /* For Empty:0' TS2200 library A to D:1-5, LRA Library: 6 */
|
||||
# else
|
||||
# define LIB_SELECTION 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef DRV_GREETING
|
||||
#define DRV_GREETING alert_750ms
|
||||
# define DRV_GREETING alert_750ms
|
||||
#endif
|
||||
#ifndef DRV_MODE_DEFAULT
|
||||
#define DRV_MODE_DEFAULT strong_click1
|
||||
# define DRV_MODE_DEFAULT strong_click1
|
||||
#endif
|
||||
|
||||
/* Control 1 register settings */
|
||||
#ifndef DRIVE_TIME
|
||||
#define DRIVE_TIME 25
|
||||
# define DRIVE_TIME 25
|
||||
#endif
|
||||
#ifndef AC_COUPLE
|
||||
#define AC_COUPLE 0
|
||||
# define AC_COUPLE 0
|
||||
#endif
|
||||
#ifndef STARTUP_BOOST
|
||||
#define STARTUP_BOOST 1
|
||||
# define STARTUP_BOOST 1
|
||||
#endif
|
||||
|
||||
/* Control 2 Settings */
|
||||
#ifndef BIDIR_INPUT
|
||||
#define BIDIR_INPUT 1
|
||||
# define BIDIR_INPUT 1
|
||||
#endif
|
||||
#ifndef BRAKE_STAB
|
||||
#define BRAKE_STAB 1 /* Loopgain is reduced when braking is almost complete to improve stability */
|
||||
# define BRAKE_STAB 1 /* Loopgain is reduced when braking is almost complete to improve stability */
|
||||
#endif
|
||||
#ifndef SAMPLE_TIME
|
||||
#define SAMPLE_TIME 3
|
||||
#ifndef SAMPLE_TIME
|
||||
# define SAMPLE_TIME 3
|
||||
#endif
|
||||
#ifndef BLANKING_TIME
|
||||
#define BLANKING_TIME 1
|
||||
# define BLANKING_TIME 1
|
||||
#endif
|
||||
#ifndef IDISS_TIME
|
||||
#define IDISS_TIME 1
|
||||
# define IDISS_TIME 1
|
||||
#endif
|
||||
|
||||
/* Control 3 settings */
|
||||
#ifndef NG_THRESH
|
||||
#define NG_THRESH 2
|
||||
# define NG_THRESH 2
|
||||
#endif
|
||||
#ifndef ERM_OPEN_LOOP
|
||||
#define ERM_OPEN_LOOP 1
|
||||
# define ERM_OPEN_LOOP 1
|
||||
#endif
|
||||
#ifndef SUPPLY_COMP_DIS
|
||||
#define SUPPLY_COMP_DIS 0
|
||||
# define SUPPLY_COMP_DIS 0
|
||||
#endif
|
||||
#ifndef DATA_FORMAT_RTO
|
||||
#define DATA_FORMAT_RTO 0
|
||||
# define DATA_FORMAT_RTO 0
|
||||
#endif
|
||||
#ifndef LRA_DRIVE_MODE
|
||||
#define LRA_DRIVE_MODE 0
|
||||
# define LRA_DRIVE_MODE 0
|
||||
#endif
|
||||
#ifndef N_PWM_ANALOG
|
||||
#define N_PWM_ANALOG 0
|
||||
# define N_PWM_ANALOG 0
|
||||
#endif
|
||||
#ifndef LRA_OPEN_LOOP
|
||||
#define LRA_OPEN_LOOP 0
|
||||
# define LRA_OPEN_LOOP 0
|
||||
#endif
|
||||
|
||||
/* Control 4 settings */
|
||||
#ifndef ZC_DET_TIME
|
||||
#define ZC_DET_TIME 0
|
||||
# define ZC_DET_TIME 0
|
||||
#endif
|
||||
#ifndef AUTO_CAL_TIME
|
||||
#define AUTO_CAL_TIME 3
|
||||
# define AUTO_CAL_TIME 3
|
||||
#endif
|
||||
|
||||
/* register defines -------------------------------------------------------- */
|
||||
#define DRV2605L_BASE_ADDRESS 0x5A /* DRV2605L Base address */
|
||||
#define DRV_STATUS 0x00
|
||||
#define DRV_MODE 0x01
|
||||
#define DRV_RTP_INPUT 0x02
|
||||
#define DRV_LIB_SELECTION 0x03
|
||||
#define DRV_WAVEFORM_SEQ_1 0x04
|
||||
#define DRV_WAVEFORM_SEQ_2 0x05
|
||||
#define DRV_WAVEFORM_SEQ_3 0x06
|
||||
#define DRV_WAVEFORM_SEQ_4 0x07
|
||||
#define DRV_WAVEFORM_SEQ_5 0x08
|
||||
#define DRV_WAVEFORM_SEQ_6 0x09
|
||||
#define DRV_WAVEFORM_SEQ_7 0x0A
|
||||
#define DRV_WAVEFORM_SEQ_8 0x0B
|
||||
#define DRV_GO 0x0C
|
||||
#define DRV_OVERDRIVE_TIME_OFFSET 0x0D
|
||||
#define DRV_SUSTAIN_TIME_OFFSET_P 0x0E
|
||||
#define DRV_SUSTAIN_TIME_OFFSET_N 0x0F
|
||||
#define DRV_BRAKE_TIME_OFFSET 0x10
|
||||
#define DRV_AUDIO_2_VIBE_CTRL 0x11
|
||||
#define DRV_AUDIO_2_VIBE_MIN_IN 0x12
|
||||
#define DRV_AUDIO_2_VIBE_MAX_IN 0x13
|
||||
#define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14
|
||||
#define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15
|
||||
#define DRV_RATED_VOLT 0x16
|
||||
#define DRV_OVERDRIVE_CLAMP_VOLT 0x17
|
||||
#define DRV_AUTO_CALIB_COMP_RESULT 0x18
|
||||
#define DRV_AUTO_CALIB_BEMF_RESULT 0x19
|
||||
#define DRV_FEEDBACK_CTRL 0x1A
|
||||
#define DRV_CTRL_1 0x1B
|
||||
#define DRV_CTRL_2 0x1C
|
||||
#define DRV_CTRL_3 0x1D
|
||||
#define DRV_CTRL_4 0x1E
|
||||
#define DRV_CTRL_5 0x1F
|
||||
#define DRV_OPEN_LOOP_PERIOD 0x20
|
||||
#define DRV_VBAT_VOLT_MONITOR 0x21
|
||||
#define DRV_LRA_RESONANCE_PERIOD 0x22
|
||||
#define DRV2605L_BASE_ADDRESS 0x5A /* DRV2605L Base address */
|
||||
#define DRV_STATUS 0x00
|
||||
#define DRV_MODE 0x01
|
||||
#define DRV_RTP_INPUT 0x02
|
||||
#define DRV_LIB_SELECTION 0x03
|
||||
#define DRV_WAVEFORM_SEQ_1 0x04
|
||||
#define DRV_WAVEFORM_SEQ_2 0x05
|
||||
#define DRV_WAVEFORM_SEQ_3 0x06
|
||||
#define DRV_WAVEFORM_SEQ_4 0x07
|
||||
#define DRV_WAVEFORM_SEQ_5 0x08
|
||||
#define DRV_WAVEFORM_SEQ_6 0x09
|
||||
#define DRV_WAVEFORM_SEQ_7 0x0A
|
||||
#define DRV_WAVEFORM_SEQ_8 0x0B
|
||||
#define DRV_GO 0x0C
|
||||
#define DRV_OVERDRIVE_TIME_OFFSET 0x0D
|
||||
#define DRV_SUSTAIN_TIME_OFFSET_P 0x0E
|
||||
#define DRV_SUSTAIN_TIME_OFFSET_N 0x0F
|
||||
#define DRV_BRAKE_TIME_OFFSET 0x10
|
||||
#define DRV_AUDIO_2_VIBE_CTRL 0x11
|
||||
#define DRV_AUDIO_2_VIBE_MIN_IN 0x12
|
||||
#define DRV_AUDIO_2_VIBE_MAX_IN 0x13
|
||||
#define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14
|
||||
#define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15
|
||||
#define DRV_RATED_VOLT 0x16
|
||||
#define DRV_OVERDRIVE_CLAMP_VOLT 0x17
|
||||
#define DRV_AUTO_CALIB_COMP_RESULT 0x18
|
||||
#define DRV_AUTO_CALIB_BEMF_RESULT 0x19
|
||||
#define DRV_FEEDBACK_CTRL 0x1A
|
||||
#define DRV_CTRL_1 0x1B
|
||||
#define DRV_CTRL_2 0x1C
|
||||
#define DRV_CTRL_3 0x1D
|
||||
#define DRV_CTRL_4 0x1E
|
||||
#define DRV_CTRL_5 0x1F
|
||||
#define DRV_OPEN_LOOP_PERIOD 0x20
|
||||
#define DRV_VBAT_VOLT_MONITOR 0x21
|
||||
#define DRV_LRA_RESONANCE_PERIOD 0x22
|
||||
|
||||
void DRV_init(void);
|
||||
void DRV_write(const uint8_t drv_register, const uint8_t settings);
|
||||
void DRV_init(void);
|
||||
void DRV_write(const uint8_t drv_register, const uint8_t settings);
|
||||
uint8_t DRV_read(const uint8_t regaddress);
|
||||
void DRV_pulse(const uint8_t sequence);
|
||||
void DRV_pulse(const uint8_t sequence);
|
||||
|
||||
typedef enum DRV_EFFECT{
|
||||
clear_sequence = 0,
|
||||
strong_click = 1,
|
||||
strong_click_60 = 2,
|
||||
strong_click_30 = 3,
|
||||
sharp_click = 4,
|
||||
sharp_click_60 = 5,
|
||||
sharp_click_30 = 6,
|
||||
soft_bump = 7,
|
||||
soft_bump_60 = 8,
|
||||
soft_bump_30 = 9,
|
||||
dbl_click = 10,
|
||||
dbl_click_60 = 11,
|
||||
trp_click = 12,
|
||||
soft_fuzz = 13,
|
||||
strong_buzz = 14,
|
||||
alert_750ms = 15,
|
||||
alert_1000ms = 16,
|
||||
strong_click1 = 17,
|
||||
strong_click2_80 = 18,
|
||||
strong_click3_60 = 19,
|
||||
strong_click4_30 = 20,
|
||||
medium_click1 = 21,
|
||||
medium_click2_80 = 22,
|
||||
medium_click3_60 = 23,
|
||||
sharp_tick1 = 24,
|
||||
sharp_tick2_80 = 25,
|
||||
sharp_tick3_60 = 26,
|
||||
sh_dblclick_str = 27,
|
||||
sh_dblclick_str_80 = 28,
|
||||
sh_dblclick_str_60 = 29,
|
||||
sh_dblclick_str_30 = 30,
|
||||
sh_dblclick_med = 31,
|
||||
sh_dblclick_med_80 = 32,
|
||||
sh_dblclick_med_60 = 33,
|
||||
sh_dblsharp_tick = 34,
|
||||
sh_dblsharp_tick_80 = 35,
|
||||
sh_dblsharp_tick_60 = 36,
|
||||
lg_dblclick_str = 37,
|
||||
lg_dblclick_str_80 = 38,
|
||||
lg_dblclick_str_60 = 39,
|
||||
lg_dblclick_str_30 = 40,
|
||||
lg_dblclick_med = 41,
|
||||
lg_dblclick_med_80 = 42,
|
||||
lg_dblclick_med_60 = 43,
|
||||
lg_dblsharp_tick = 44,
|
||||
lg_dblsharp_tick_80 = 45,
|
||||
lg_dblsharp_tick_60 = 46,
|
||||
buzz = 47,
|
||||
buzz_80 = 48,
|
||||
buzz_60 = 49,
|
||||
buzz_40 = 50,
|
||||
buzz_20 = 51,
|
||||
pulsing_strong = 52,
|
||||
pulsing_strong_80 = 53,
|
||||
pulsing_medium = 54,
|
||||
pulsing_medium_80 = 55,
|
||||
pulsing_sharp = 56,
|
||||
pulsing_sharp_80 = 57,
|
||||
transition_click = 58,
|
||||
transition_click_80 = 59,
|
||||
transition_click_60 = 60,
|
||||
transition_click_40 = 61,
|
||||
transition_click_20 = 62,
|
||||
transition_click_10 = 63,
|
||||
transition_hum = 64,
|
||||
transition_hum_80 = 65,
|
||||
transition_hum_60 = 66,
|
||||
transition_hum_40 = 67,
|
||||
transition_hum_20 = 68,
|
||||
transition_hum_10 = 69,
|
||||
transition_rampdown_long_smooth1 = 70,
|
||||
transition_rampdown_long_smooth2 = 71,
|
||||
transition_rampdown_med_smooth1 = 72,
|
||||
transition_rampdown_med_smooth2 = 73,
|
||||
transition_rampdown_short_smooth1 = 74,
|
||||
transition_rampdown_short_smooth2 = 75,
|
||||
transition_rampdown_long_sharp1 = 76,
|
||||
transition_rampdown_long_sharp2 = 77,
|
||||
transition_rampdown_med_sharp1 = 78,
|
||||
transition_rampdown_med_sharp2 = 79,
|
||||
transition_rampdown_short_sharp1 = 80,
|
||||
transition_rampdown_short_sharp2 = 81,
|
||||
transition_rampup_long_smooth1 = 82,
|
||||
transition_rampup_long_smooth2 = 83,
|
||||
transition_rampup_med_smooth1 = 84,
|
||||
transition_rampup_med_smooth2 = 85,
|
||||
transition_rampup_short_smooth1 = 86,
|
||||
transition_rampup_short_smooth2 = 87,
|
||||
transition_rampup_long_sharp1 = 88,
|
||||
transition_rampup_long_sharp2 = 89,
|
||||
transition_rampup_med_sharp1 = 90,
|
||||
transition_rampup_med_sharp2 = 91,
|
||||
transition_rampup_short_sharp1 = 92,
|
||||
transition_rampup_short_sharp2 = 93,
|
||||
transition_rampdown_long_smooth1_50 = 94,
|
||||
transition_rampdown_long_smooth2_50 = 95,
|
||||
transition_rampdown_med_smooth1_50 = 96,
|
||||
transition_rampdown_med_smooth2_50 = 97,
|
||||
transition_rampdown_short_smooth1_50 = 98,
|
||||
transition_rampdown_short_smooth2_50 = 99,
|
||||
transition_rampdown_long_sharp1_50 = 100,
|
||||
transition_rampdown_long_sharp2_50 = 101,
|
||||
transition_rampdown_med_sharp1_50 = 102,
|
||||
transition_rampdown_med_sharp2_50 = 103,
|
||||
transition_rampdown_short_sharp1_50 = 104,
|
||||
transition_rampdown_short_sharp2_50 = 105,
|
||||
transition_rampup_long_smooth1_50 = 106,
|
||||
transition_rampup_long_smooth2_50 = 107,
|
||||
transition_rampup_med_smooth1_50 = 108,
|
||||
transition_rampup_med_smooth2_50 = 109,
|
||||
transition_rampup_short_smooth1_50 = 110,
|
||||
transition_rampup_short_smooth2_50 = 111,
|
||||
transition_rampup_long_sharp1_50 = 112,
|
||||
transition_rampup_long_sharp2_50 = 113,
|
||||
transition_rampup_med_sharp1_50 = 114,
|
||||
transition_rampup_med_sharp2_50 = 115,
|
||||
transition_rampup_short_sharp1_50 = 116,
|
||||
transition_rampup_short_sharp2_50 = 117,
|
||||
long_buzz_for_programmatic_stopping = 118,
|
||||
smooth_hum1_50 = 119,
|
||||
smooth_hum2_40 = 120,
|
||||
smooth_hum3_30 = 121,
|
||||
smooth_hum4_20 = 122,
|
||||
smooth_hum5_10 = 123,
|
||||
drv_effect_max = 124,
|
||||
typedef enum DRV_EFFECT {
|
||||
clear_sequence = 0,
|
||||
strong_click = 1,
|
||||
strong_click_60 = 2,
|
||||
strong_click_30 = 3,
|
||||
sharp_click = 4,
|
||||
sharp_click_60 = 5,
|
||||
sharp_click_30 = 6,
|
||||
soft_bump = 7,
|
||||
soft_bump_60 = 8,
|
||||
soft_bump_30 = 9,
|
||||
dbl_click = 10,
|
||||
dbl_click_60 = 11,
|
||||
trp_click = 12,
|
||||
soft_fuzz = 13,
|
||||
strong_buzz = 14,
|
||||
alert_750ms = 15,
|
||||
alert_1000ms = 16,
|
||||
strong_click1 = 17,
|
||||
strong_click2_80 = 18,
|
||||
strong_click3_60 = 19,
|
||||
strong_click4_30 = 20,
|
||||
medium_click1 = 21,
|
||||
medium_click2_80 = 22,
|
||||
medium_click3_60 = 23,
|
||||
sharp_tick1 = 24,
|
||||
sharp_tick2_80 = 25,
|
||||
sharp_tick3_60 = 26,
|
||||
sh_dblclick_str = 27,
|
||||
sh_dblclick_str_80 = 28,
|
||||
sh_dblclick_str_60 = 29,
|
||||
sh_dblclick_str_30 = 30,
|
||||
sh_dblclick_med = 31,
|
||||
sh_dblclick_med_80 = 32,
|
||||
sh_dblclick_med_60 = 33,
|
||||
sh_dblsharp_tick = 34,
|
||||
sh_dblsharp_tick_80 = 35,
|
||||
sh_dblsharp_tick_60 = 36,
|
||||
lg_dblclick_str = 37,
|
||||
lg_dblclick_str_80 = 38,
|
||||
lg_dblclick_str_60 = 39,
|
||||
lg_dblclick_str_30 = 40,
|
||||
lg_dblclick_med = 41,
|
||||
lg_dblclick_med_80 = 42,
|
||||
lg_dblclick_med_60 = 43,
|
||||
lg_dblsharp_tick = 44,
|
||||
lg_dblsharp_tick_80 = 45,
|
||||
lg_dblsharp_tick_60 = 46,
|
||||
buzz = 47,
|
||||
buzz_80 = 48,
|
||||
buzz_60 = 49,
|
||||
buzz_40 = 50,
|
||||
buzz_20 = 51,
|
||||
pulsing_strong = 52,
|
||||
pulsing_strong_80 = 53,
|
||||
pulsing_medium = 54,
|
||||
pulsing_medium_80 = 55,
|
||||
pulsing_sharp = 56,
|
||||
pulsing_sharp_80 = 57,
|
||||
transition_click = 58,
|
||||
transition_click_80 = 59,
|
||||
transition_click_60 = 60,
|
||||
transition_click_40 = 61,
|
||||
transition_click_20 = 62,
|
||||
transition_click_10 = 63,
|
||||
transition_hum = 64,
|
||||
transition_hum_80 = 65,
|
||||
transition_hum_60 = 66,
|
||||
transition_hum_40 = 67,
|
||||
transition_hum_20 = 68,
|
||||
transition_hum_10 = 69,
|
||||
transition_rampdown_long_smooth1 = 70,
|
||||
transition_rampdown_long_smooth2 = 71,
|
||||
transition_rampdown_med_smooth1 = 72,
|
||||
transition_rampdown_med_smooth2 = 73,
|
||||
transition_rampdown_short_smooth1 = 74,
|
||||
transition_rampdown_short_smooth2 = 75,
|
||||
transition_rampdown_long_sharp1 = 76,
|
||||
transition_rampdown_long_sharp2 = 77,
|
||||
transition_rampdown_med_sharp1 = 78,
|
||||
transition_rampdown_med_sharp2 = 79,
|
||||
transition_rampdown_short_sharp1 = 80,
|
||||
transition_rampdown_short_sharp2 = 81,
|
||||
transition_rampup_long_smooth1 = 82,
|
||||
transition_rampup_long_smooth2 = 83,
|
||||
transition_rampup_med_smooth1 = 84,
|
||||
transition_rampup_med_smooth2 = 85,
|
||||
transition_rampup_short_smooth1 = 86,
|
||||
transition_rampup_short_smooth2 = 87,
|
||||
transition_rampup_long_sharp1 = 88,
|
||||
transition_rampup_long_sharp2 = 89,
|
||||
transition_rampup_med_sharp1 = 90,
|
||||
transition_rampup_med_sharp2 = 91,
|
||||
transition_rampup_short_sharp1 = 92,
|
||||
transition_rampup_short_sharp2 = 93,
|
||||
transition_rampdown_long_smooth1_50 = 94,
|
||||
transition_rampdown_long_smooth2_50 = 95,
|
||||
transition_rampdown_med_smooth1_50 = 96,
|
||||
transition_rampdown_med_smooth2_50 = 97,
|
||||
transition_rampdown_short_smooth1_50 = 98,
|
||||
transition_rampdown_short_smooth2_50 = 99,
|
||||
transition_rampdown_long_sharp1_50 = 100,
|
||||
transition_rampdown_long_sharp2_50 = 101,
|
||||
transition_rampdown_med_sharp1_50 = 102,
|
||||
transition_rampdown_med_sharp2_50 = 103,
|
||||
transition_rampdown_short_sharp1_50 = 104,
|
||||
transition_rampdown_short_sharp2_50 = 105,
|
||||
transition_rampup_long_smooth1_50 = 106,
|
||||
transition_rampup_long_smooth2_50 = 107,
|
||||
transition_rampup_med_smooth1_50 = 108,
|
||||
transition_rampup_med_smooth2_50 = 109,
|
||||
transition_rampup_short_smooth1_50 = 110,
|
||||
transition_rampup_short_smooth2_50 = 111,
|
||||
transition_rampup_long_sharp1_50 = 112,
|
||||
transition_rampup_long_sharp2_50 = 113,
|
||||
transition_rampup_med_sharp1_50 = 114,
|
||||
transition_rampup_med_sharp2_50 = 115,
|
||||
transition_rampup_short_sharp1_50 = 116,
|
||||
transition_rampup_short_sharp2_50 = 117,
|
||||
long_buzz_for_programmatic_stopping = 118,
|
||||
smooth_hum1_50 = 119,
|
||||
smooth_hum2_40 = 120,
|
||||
smooth_hum3_30 = 121,
|
||||
smooth_hum4_20 = 122,
|
||||
smooth_hum5_10 = 123,
|
||||
drv_effect_max = 124,
|
||||
} DRV_EFFECT;
|
||||
|
||||
/* Register bit array unions */
|
||||
|
||||
typedef union DRVREG_STATUS { /* register 0x00 */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t OC_DETECT :1; /* set to 1 when overcurrent event is detected */
|
||||
uint8_t OVER_TEMP :1; /* set to 1 when device exceeds temp threshold */
|
||||
uint8_t FB_STS :1; /* set to 1 when feedback controller has timed out */
|
||||
/* auto-calibration routine and diagnostic result
|
||||
* result | auto-calibation | diagnostic |
|
||||
* 0 | passed | actuator func normal |
|
||||
* 1 | failed | actuator func fault* |
|
||||
* * actuator is not present or is shorted, timing out, or giving out–of-range back-EMF */
|
||||
uint8_t DIAG_RESULT :1;
|
||||
uint8_t :1;
|
||||
uint8_t DEVICE_ID :3; /* Device IDs 3: DRV2605 4: DRV2604 5: DRV2604L 6: DRV2605L */
|
||||
} Bits;
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t OC_DETECT : 1; /* set to 1 when overcurrent event is detected */
|
||||
uint8_t OVER_TEMP : 1; /* set to 1 when device exceeds temp threshold */
|
||||
uint8_t FB_STS : 1; /* set to 1 when feedback controller has timed out */
|
||||
/* auto-calibration routine and diagnostic result
|
||||
* result | auto-calibation | diagnostic |
|
||||
* 0 | passed | actuator func normal |
|
||||
* 1 | failed | actuator func fault* |
|
||||
* * actuator is not present or is shorted, timing out, or giving out–of-range back-EMF */
|
||||
uint8_t DIAG_RESULT : 1;
|
||||
uint8_t : 1;
|
||||
uint8_t DEVICE_ID : 3; /* Device IDs 3: DRV2605 4: DRV2604 5: DRV2604L 6: DRV2605L */
|
||||
} Bits;
|
||||
} DRVREG_STATUS;
|
||||
|
||||
typedef union DRVREG_MODE { /* register 0x01 */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t MODE :3; /* Mode setting */
|
||||
uint8_t :3;
|
||||
uint8_t STANDBY :1; /* 0:standby 1:ready */
|
||||
} Bits;
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t MODE : 3; /* Mode setting */
|
||||
uint8_t : 3;
|
||||
uint8_t STANDBY : 1; /* 0:standby 1:ready */
|
||||
} Bits;
|
||||
} DRVREG_MODE;
|
||||
|
||||
typedef union DRVREG_WAIT {
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t WAIT_MODE :1; /* Set to 1 to interpret as wait for next 7 bits x10ms */
|
||||
uint8_t WAIT_TIME :7;
|
||||
} Bits;
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t WAIT_MODE : 1; /* Set to 1 to interpret as wait for next 7 bits x10ms */
|
||||
uint8_t WAIT_TIME : 7;
|
||||
} Bits;
|
||||
} DRVREG_WAIT;
|
||||
|
||||
typedef union DRVREG_FBR{ /* register 0x1A */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t BEMF_GAIN :2;
|
||||
uint8_t LOOP_GAIN :2;
|
||||
uint8_t BRAKE_FACTOR :3;
|
||||
uint8_t ERM_LRA :1;
|
||||
} Bits;
|
||||
typedef union DRVREG_FBR { /* register 0x1A */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t BEMF_GAIN : 2;
|
||||
uint8_t LOOP_GAIN : 2;
|
||||
uint8_t BRAKE_FACTOR : 3;
|
||||
uint8_t ERM_LRA : 1;
|
||||
} Bits;
|
||||
} DRVREG_FBR;
|
||||
|
||||
typedef union DRVREG_CTRL1{ /* register 0x1B */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C1_DRIVE_TIME :5;
|
||||
uint8_t C1_AC_COUPLE :1;
|
||||
uint8_t :1;
|
||||
uint8_t C1_STARTUP_BOOST :1;
|
||||
} Bits;
|
||||
typedef union DRVREG_CTRL1 { /* register 0x1B */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C1_DRIVE_TIME : 5;
|
||||
uint8_t C1_AC_COUPLE : 1;
|
||||
uint8_t : 1;
|
||||
uint8_t C1_STARTUP_BOOST : 1;
|
||||
} Bits;
|
||||
} DRVREG_CTRL1;
|
||||
|
||||
typedef union DRVREG_CTRL2{ /* register 0x1C */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C2_IDISS_TIME :2;
|
||||
uint8_t C2_BLANKING_TIME :2;
|
||||
uint8_t C2_SAMPLE_TIME :2;
|
||||
uint8_t C2_BRAKE_STAB :1;
|
||||
uint8_t C2_BIDIR_INPUT :1;
|
||||
} Bits;
|
||||
typedef union DRVREG_CTRL2 { /* register 0x1C */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C2_IDISS_TIME : 2;
|
||||
uint8_t C2_BLANKING_TIME : 2;
|
||||
uint8_t C2_SAMPLE_TIME : 2;
|
||||
uint8_t C2_BRAKE_STAB : 1;
|
||||
uint8_t C2_BIDIR_INPUT : 1;
|
||||
} Bits;
|
||||
} DRVREG_CTRL2;
|
||||
|
||||
typedef union DRVREG_CTRL3{ /* register 0x1D */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C3_LRA_OPEN_LOOP :1;
|
||||
uint8_t C3_N_PWM_ANALOG :1;
|
||||
uint8_t C3_LRA_DRIVE_MODE :1;
|
||||
uint8_t C3_DATA_FORMAT_RTO :1;
|
||||
uint8_t C3_SUPPLY_COMP_DIS :1;
|
||||
uint8_t C3_ERM_OPEN_LOOP :1;
|
||||
uint8_t C3_NG_THRESH :2;
|
||||
} Bits;
|
||||
typedef union DRVREG_CTRL3 { /* register 0x1D */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C3_LRA_OPEN_LOOP : 1;
|
||||
uint8_t C3_N_PWM_ANALOG : 1;
|
||||
uint8_t C3_LRA_DRIVE_MODE : 1;
|
||||
uint8_t C3_DATA_FORMAT_RTO : 1;
|
||||
uint8_t C3_SUPPLY_COMP_DIS : 1;
|
||||
uint8_t C3_ERM_OPEN_LOOP : 1;
|
||||
uint8_t C3_NG_THRESH : 2;
|
||||
} Bits;
|
||||
} DRVREG_CTRL3;
|
||||
|
||||
typedef union DRVREG_CTRL4{ /* register 0x1E */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C4_OTP_PROGRAM :1;
|
||||
uint8_t :1;
|
||||
uint8_t C4_OTP_STATUS :1;
|
||||
uint8_t :1;
|
||||
uint8_t C4_AUTO_CAL_TIME :2;
|
||||
uint8_t C4_ZC_DET_TIME :2;
|
||||
} Bits;
|
||||
typedef union DRVREG_CTRL4 { /* register 0x1E */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C4_OTP_PROGRAM : 1;
|
||||
uint8_t : 1;
|
||||
uint8_t C4_OTP_STATUS : 1;
|
||||
uint8_t : 1;
|
||||
uint8_t C4_AUTO_CAL_TIME : 2;
|
||||
uint8_t C4_ZC_DET_TIME : 2;
|
||||
} Bits;
|
||||
} DRVREG_CTRL4;
|
||||
|
||||
typedef union DRVREG_CTRL5{ /* register 0x1F */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C5_IDISS_TIME :2;
|
||||
uint8_t C5_BLANKING_TIME :2;
|
||||
uint8_t C5_PLAYBACK_INTERVAL :1;
|
||||
uint8_t C5_LRA_AUTO_OPEN_LOOP :1;
|
||||
uint8_t C5_AUTO_OL_CNT :2;
|
||||
} Bits;
|
||||
typedef union DRVREG_CTRL5 { /* register 0x1F */
|
||||
uint8_t Byte;
|
||||
struct {
|
||||
uint8_t C5_IDISS_TIME : 2;
|
||||
uint8_t C5_BLANKING_TIME : 2;
|
||||
uint8_t C5_PLAYBACK_INTERVAL : 1;
|
||||
uint8_t C5_LRA_AUTO_OPEN_LOOP : 1;
|
||||
uint8_t C5_AUTO_OL_CNT : 2;
|
||||
} Bits;
|
||||
} DRVREG_CTRL5;
|
@ -19,230 +19,248 @@
|
||||
#include "progmem.h"
|
||||
#include "debug.h"
|
||||
#ifdef DRV2605L
|
||||
#include "DRV2605L.h"
|
||||
# include "DRV2605L.h"
|
||||
#endif
|
||||
#ifdef SOLENOID_ENABLE
|
||||
#include "solenoid.h"
|
||||
# include "solenoid.h"
|
||||
#endif
|
||||
|
||||
haptic_config_t haptic_config;
|
||||
|
||||
void haptic_init(void) {
|
||||
debug_enable = 1; //Debug is ON!
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
haptic_config.raw = eeconfig_read_haptic();
|
||||
if (haptic_config.mode < 1){
|
||||
haptic_config.mode = 1;
|
||||
}
|
||||
if (!haptic_config.mode){
|
||||
dprintf("No haptic config found in eeprom, setting default configs\n");
|
||||
haptic_reset();
|
||||
}
|
||||
#ifdef SOLENOID_ENABLE
|
||||
debug_enable = 1; // Debug is ON!
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
haptic_config.raw = eeconfig_read_haptic();
|
||||
if (haptic_config.mode < 1) {
|
||||
haptic_config.mode = 1;
|
||||
}
|
||||
if (!haptic_config.mode) {
|
||||
dprintf("No haptic config found in eeprom, setting default configs\n");
|
||||
haptic_reset();
|
||||
}
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_setup();
|
||||
dprintf("Solenoid driver initialized\n");
|
||||
#endif
|
||||
#ifdef DRV2605L
|
||||
#endif
|
||||
#ifdef DRV2605L
|
||||
DRV_init();
|
||||
dprintf("DRV2605 driver initialized\n");
|
||||
#endif
|
||||
eeconfig_debug_haptic();
|
||||
#endif
|
||||
eeconfig_debug_haptic();
|
||||
}
|
||||
|
||||
void haptic_task(void) {
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_check();
|
||||
#endif
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_check();
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeconfig_debug_haptic(void) {
|
||||
dprintf("haptic_config eprom\n");
|
||||
dprintf("haptic_config.enable = %d\n", haptic_config.enable);
|
||||
dprintf("haptic_config.mode = %d\n", haptic_config.mode);
|
||||
dprintf("haptic_config eprom\n");
|
||||
dprintf("haptic_config.enable = %d\n", haptic_config.enable);
|
||||
dprintf("haptic_config.mode = %d\n", haptic_config.mode);
|
||||
}
|
||||
|
||||
void haptic_enable(void) {
|
||||
haptic_config.enable = 1;
|
||||
xprintf("haptic_config.enable = %u\n", haptic_config.enable);
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
haptic_config.enable = 1;
|
||||
xprintf("haptic_config.enable = %u\n", haptic_config.enable);
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
}
|
||||
|
||||
void haptic_disable(void) {
|
||||
haptic_config.enable = 0;
|
||||
xprintf("haptic_config.enable = %u\n", haptic_config.enable);
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
haptic_config.enable = 0;
|
||||
xprintf("haptic_config.enable = %u\n", haptic_config.enable);
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
}
|
||||
|
||||
void haptic_toggle(void) {
|
||||
if (haptic_config.enable) {
|
||||
haptic_disable();
|
||||
} else {
|
||||
haptic_enable();
|
||||
}
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
if (haptic_config.enable) {
|
||||
haptic_disable();
|
||||
} else {
|
||||
haptic_enable();
|
||||
}
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
}
|
||||
|
||||
void haptic_feedback_toggle(void){
|
||||
haptic_config.feedback++;
|
||||
if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX)
|
||||
haptic_config.feedback = KEY_PRESS;
|
||||
xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
void haptic_feedback_toggle(void) {
|
||||
haptic_config.feedback++;
|
||||
if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) haptic_config.feedback = KEY_PRESS;
|
||||
xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
}
|
||||
|
||||
void haptic_buzz_toggle(void) {
|
||||
bool buzz_stat = !haptic_config.buzz;
|
||||
haptic_config.buzz = buzz_stat;
|
||||
haptic_set_buzz(buzz_stat);
|
||||
bool buzz_stat = !haptic_config.buzz;
|
||||
haptic_config.buzz = buzz_stat;
|
||||
haptic_set_buzz(buzz_stat);
|
||||
}
|
||||
|
||||
void haptic_mode_increase(void) {
|
||||
uint8_t mode = haptic_config.mode + 1;
|
||||
#ifdef DRV2605L
|
||||
if (haptic_config.mode >= drv_effect_max) {
|
||||
mode = 1;
|
||||
}
|
||||
#endif
|
||||
uint8_t mode = haptic_config.mode + 1;
|
||||
#ifdef DRV2605L
|
||||
if (haptic_config.mode >= drv_effect_max) {
|
||||
mode = 1;
|
||||
}
|
||||
#endif
|
||||
haptic_set_mode(mode);
|
||||
}
|
||||
|
||||
void haptic_mode_decrease(void) {
|
||||
uint8_t mode = haptic_config.mode -1;
|
||||
#ifdef DRV2605L
|
||||
if (haptic_config.mode < 1) {
|
||||
mode = (drv_effect_max - 1);
|
||||
}
|
||||
#endif
|
||||
haptic_set_mode(mode);
|
||||
uint8_t mode = haptic_config.mode - 1;
|
||||
#ifdef DRV2605L
|
||||
if (haptic_config.mode < 1) {
|
||||
mode = (drv_effect_max - 1);
|
||||
}
|
||||
#endif
|
||||
haptic_set_mode(mode);
|
||||
}
|
||||
|
||||
void haptic_dwell_increase(void) {
|
||||
uint8_t dwell = haptic_config.dwell + 1;
|
||||
#ifdef SOLENOID_ENABLE
|
||||
if (haptic_config.dwell >= SOLENOID_MAX_DWELL) {
|
||||
dwell = 1;
|
||||
}
|
||||
solenoid_set_dwell(dwell);
|
||||
#endif
|
||||
haptic_set_dwell(dwell);
|
||||
uint8_t dwell = haptic_config.dwell + 1;
|
||||
#ifdef SOLENOID_ENABLE
|
||||
if (haptic_config.dwell >= SOLENOID_MAX_DWELL) {
|
||||
dwell = 1;
|
||||
}
|
||||
solenoid_set_dwell(dwell);
|
||||
#endif
|
||||
haptic_set_dwell(dwell);
|
||||
}
|
||||
|
||||
void haptic_dwell_decrease(void) {
|
||||
uint8_t dwell = haptic_config.dwell -1;
|
||||
#ifdef SOLENOID_ENABLE
|
||||
if (haptic_config.dwell < SOLENOID_MIN_DWELL) {
|
||||
dwell = SOLENOID_MAX_DWELL;
|
||||
}
|
||||
solenoid_set_dwell(dwell);
|
||||
#endif
|
||||
haptic_set_dwell(dwell);
|
||||
uint8_t dwell = haptic_config.dwell - 1;
|
||||
#ifdef SOLENOID_ENABLE
|
||||
if (haptic_config.dwell < SOLENOID_MIN_DWELL) {
|
||||
dwell = SOLENOID_MAX_DWELL;
|
||||
}
|
||||
solenoid_set_dwell(dwell);
|
||||
#endif
|
||||
haptic_set_dwell(dwell);
|
||||
}
|
||||
|
||||
void haptic_reset(void){
|
||||
haptic_config.enable = true;
|
||||
uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT;
|
||||
haptic_config.feedback = feedback;
|
||||
#ifdef DRV2605L
|
||||
uint8_t mode = HAPTIC_MODE_DEFAULT;
|
||||
void haptic_reset(void) {
|
||||
haptic_config.enable = true;
|
||||
uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT;
|
||||
haptic_config.feedback = feedback;
|
||||
#ifdef DRV2605L
|
||||
uint8_t mode = HAPTIC_MODE_DEFAULT;
|
||||
haptic_config.mode = mode;
|
||||
#endif
|
||||
#ifdef SOLENOID_ENABLE
|
||||
uint8_t dwell = SOLENOID_DEFAULT_DWELL;
|
||||
#endif
|
||||
#ifdef SOLENOID_ENABLE
|
||||
uint8_t dwell = SOLENOID_DEFAULT_DWELL;
|
||||
haptic_config.dwell = dwell;
|
||||
#endif
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
|
||||
xprintf("haptic_config.mode = %u\n", haptic_config.mode);
|
||||
#endif
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
|
||||
xprintf("haptic_config.mode = %u\n", haptic_config.mode);
|
||||
}
|
||||
|
||||
void haptic_set_feedback(uint8_t feedback) {
|
||||
haptic_config.feedback = feedback;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
|
||||
haptic_config.feedback = feedback;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
|
||||
}
|
||||
|
||||
void haptic_set_mode(uint8_t mode) {
|
||||
haptic_config.mode = mode;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.mode = %u\n", haptic_config.mode);
|
||||
haptic_config.mode = mode;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.mode = %u\n", haptic_config.mode);
|
||||
}
|
||||
|
||||
void haptic_set_buzz(uint8_t buzz) {
|
||||
haptic_config.buzz = buzz;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
|
||||
haptic_config.buzz = buzz;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
|
||||
}
|
||||
|
||||
void haptic_set_dwell(uint8_t dwell) {
|
||||
haptic_config.dwell = dwell;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
|
||||
haptic_config.dwell = dwell;
|
||||
eeconfig_update_haptic(haptic_config.raw);
|
||||
xprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
|
||||
}
|
||||
|
||||
uint8_t haptic_get_mode(void) {
|
||||
if (!haptic_config.enable){
|
||||
return false;
|
||||
}
|
||||
return haptic_config.mode;
|
||||
if (!haptic_config.enable) {
|
||||
return false;
|
||||
}
|
||||
return haptic_config.mode;
|
||||
}
|
||||
|
||||
uint8_t haptic_get_feedback(void) {
|
||||
if (!haptic_config.enable){
|
||||
return false;
|
||||
}
|
||||
return haptic_config.feedback;
|
||||
if (!haptic_config.enable) {
|
||||
return false;
|
||||
}
|
||||
return haptic_config.feedback;
|
||||
}
|
||||
|
||||
uint8_t haptic_get_dwell(void) {
|
||||
if (!haptic_config.enable){
|
||||
return false;
|
||||
}
|
||||
return haptic_config.dwell;
|
||||
if (!haptic_config.enable) {
|
||||
return false;
|
||||
}
|
||||
return haptic_config.dwell;
|
||||
}
|
||||
|
||||
void haptic_play(void) {
|
||||
#ifdef DRV2605L
|
||||
uint8_t play_eff = 0;
|
||||
play_eff = haptic_config.mode;
|
||||
DRV_pulse(play_eff);
|
||||
#endif
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_fire();
|
||||
#endif
|
||||
#ifdef DRV2605L
|
||||
uint8_t play_eff = 0;
|
||||
play_eff = haptic_config.mode;
|
||||
DRV_pulse(play_eff);
|
||||
#endif
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_fire();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool process_haptic(uint16_t keycode, keyrecord_t *record) {
|
||||
if (keycode == HPT_ON && record->event.pressed) { haptic_enable(); }
|
||||
if (keycode == HPT_OFF && record->event.pressed) { haptic_disable(); }
|
||||
if (keycode == HPT_TOG && record->event.pressed) { haptic_toggle(); }
|
||||
if (keycode == HPT_RST && record->event.pressed) { haptic_reset(); }
|
||||
if (keycode == HPT_FBK && record->event.pressed) { haptic_feedback_toggle(); }
|
||||
if (keycode == HPT_BUZ && record->event.pressed) { haptic_buzz_toggle(); }
|
||||
if (keycode == HPT_MODI && record->event.pressed) { haptic_mode_increase(); }
|
||||
if (keycode == HPT_MODD && record->event.pressed) { haptic_mode_decrease(); }
|
||||
if (keycode == HPT_DWLI && record->event.pressed) { haptic_dwell_increase(); }
|
||||
if (keycode == HPT_DWLD && record->event.pressed) { haptic_dwell_decrease(); }
|
||||
if (haptic_config.enable) {
|
||||
if ( record->event.pressed ) {
|
||||
// keypress
|
||||
if (haptic_config.feedback < 2) {
|
||||
haptic_play();
|
||||
}
|
||||
} else {
|
||||
//keyrelease
|
||||
if (haptic_config.feedback > 0) {
|
||||
haptic_play();
|
||||
}
|
||||
if (keycode == HPT_ON && record->event.pressed) {
|
||||
haptic_enable();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (keycode == HPT_OFF && record->event.pressed) {
|
||||
haptic_disable();
|
||||
}
|
||||
if (keycode == HPT_TOG && record->event.pressed) {
|
||||
haptic_toggle();
|
||||
}
|
||||
if (keycode == HPT_RST && record->event.pressed) {
|
||||
haptic_reset();
|
||||
}
|
||||
if (keycode == HPT_FBK && record->event.pressed) {
|
||||
haptic_feedback_toggle();
|
||||
}
|
||||
if (keycode == HPT_BUZ && record->event.pressed) {
|
||||
haptic_buzz_toggle();
|
||||
}
|
||||
if (keycode == HPT_MODI && record->event.pressed) {
|
||||
haptic_mode_increase();
|
||||
}
|
||||
if (keycode == HPT_MODD && record->event.pressed) {
|
||||
haptic_mode_decrease();
|
||||
}
|
||||
if (keycode == HPT_DWLI && record->event.pressed) {
|
||||
haptic_dwell_increase();
|
||||
}
|
||||
if (keycode == HPT_DWLD && record->event.pressed) {
|
||||
haptic_dwell_decrease();
|
||||
}
|
||||
if (haptic_config.enable) {
|
||||
if (record->event.pressed) {
|
||||
// keypress
|
||||
if (haptic_config.feedback < 2) {
|
||||
haptic_play();
|
||||
}
|
||||
} else {
|
||||
// keyrelease
|
||||
if (haptic_config.feedback > 0) {
|
||||
haptic_play();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void haptic_shutdown(void) {
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_shutdown();
|
||||
#endif
|
||||
|
||||
#ifdef SOLENOID_ENABLE
|
||||
solenoid_shutdown();
|
||||
#endif
|
||||
}
|
||||
|
@ -20,63 +20,57 @@
|
||||
#include <stdbool.h>
|
||||
#include "quantum.h"
|
||||
#ifdef DRV2605L
|
||||
#include "DRV2605L.h"
|
||||
# include "DRV2605L.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAPTIC_FEEDBACK_DEFAULT
|
||||
#define HAPTIC_FEEDBACK_DEFAULT 0
|
||||
# define HAPTIC_FEEDBACK_DEFAULT 0
|
||||
#endif
|
||||
#ifndef HAPTIC_MODE_DEFAULT
|
||||
#define HAPTIC_MODE_DEFAULT DRV_MODE_DEFAULT
|
||||
# define HAPTIC_MODE_DEFAULT DRV_MODE_DEFAULT
|
||||
#endif
|
||||
|
||||
/* EEPROM config settings */
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
struct {
|
||||
bool enable :1;
|
||||
uint8_t feedback :2;
|
||||
uint8_t mode :7;
|
||||
bool buzz :1;
|
||||
uint8_t dwell :7;
|
||||
uint16_t reserved :16;
|
||||
};
|
||||
uint32_t raw;
|
||||
struct {
|
||||
bool enable : 1;
|
||||
uint8_t feedback : 2;
|
||||
uint8_t mode : 7;
|
||||
bool buzz : 1;
|
||||
uint8_t dwell : 7;
|
||||
uint16_t reserved : 16;
|
||||
};
|
||||
} haptic_config_t;
|
||||
|
||||
typedef enum HAPTIC_FEEDBACK{
|
||||
KEY_PRESS,
|
||||
KEY_PRESS_RELEASE,
|
||||
KEY_RELEASE,
|
||||
HAPTIC_FEEDBACK_MAX,
|
||||
typedef enum HAPTIC_FEEDBACK {
|
||||
KEY_PRESS,
|
||||
KEY_PRESS_RELEASE,
|
||||
KEY_RELEASE,
|
||||
HAPTIC_FEEDBACK_MAX,
|
||||
} HAPTIC_FEEDBACK;
|
||||
|
||||
bool process_haptic(uint16_t keycode, keyrecord_t *record);
|
||||
void haptic_init(void);
|
||||
void haptic_task(void);
|
||||
void eeconfig_debug_haptic(void);
|
||||
void haptic_enable(void);
|
||||
void haptic_disable(void);
|
||||
void haptic_toggle(void);
|
||||
void haptic_feedback_toggle(void);
|
||||
void haptic_mode_increase(void);
|
||||
void haptic_mode_decrease(void);
|
||||
void haptic_mode(uint8_t mode);
|
||||
void haptic_reset(void);
|
||||
void haptic_set_feedback(uint8_t feedback);
|
||||
void haptic_set_mode(uint8_t mode);
|
||||
void haptic_set_dwell(uint8_t dwell);
|
||||
void haptic_set_buzz(uint8_t buzz);
|
||||
void haptic_buzz_toggle(void);
|
||||
bool process_haptic(uint16_t keycode, keyrecord_t *record);
|
||||
void haptic_init(void);
|
||||
void haptic_task(void);
|
||||
void eeconfig_debug_haptic(void);
|
||||
void haptic_enable(void);
|
||||
void haptic_disable(void);
|
||||
void haptic_toggle(void);
|
||||
void haptic_feedback_toggle(void);
|
||||
void haptic_mode_increase(void);
|
||||
void haptic_mode_decrease(void);
|
||||
void haptic_mode(uint8_t mode);
|
||||
void haptic_reset(void);
|
||||
void haptic_set_feedback(uint8_t feedback);
|
||||
void haptic_set_mode(uint8_t mode);
|
||||
void haptic_set_dwell(uint8_t dwell);
|
||||
void haptic_set_buzz(uint8_t buzz);
|
||||
void haptic_buzz_toggle(void);
|
||||
uint8_t haptic_get_mode(void);
|
||||
uint8_t haptic_get_feedback(void);
|
||||
void haptic_dwell_increase(void);
|
||||
void haptic_dwell_decrease(void);
|
||||
void haptic_dwell_increase(void);
|
||||
void haptic_dwell_decrease(void);
|
||||
|
||||
void haptic_play(void);
|
||||
void haptic_shutdown(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,91 +19,77 @@
|
||||
#include "solenoid.h"
|
||||
#include "haptic.h"
|
||||
|
||||
bool solenoid_on = false;
|
||||
bool solenoid_buzzing = false;
|
||||
uint16_t solenoid_start = 0;
|
||||
uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
|
||||
bool solenoid_on = false;
|
||||
bool solenoid_buzzing = false;
|
||||
uint16_t solenoid_start = 0;
|
||||
uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
|
||||
|
||||
extern haptic_config_t haptic_config;
|
||||
|
||||
void solenoid_buzz_on(void) { haptic_set_buzz(1); }
|
||||
|
||||
void solenoid_buzz_on(void) {
|
||||
haptic_set_buzz(1);
|
||||
}
|
||||
|
||||
void solenoid_buzz_off(void) {
|
||||
haptic_set_buzz(0);
|
||||
}
|
||||
|
||||
void solenoid_set_buzz(int buzz) {
|
||||
haptic_set_buzz(buzz);
|
||||
}
|
||||
void solenoid_buzz_off(void) { haptic_set_buzz(0); }
|
||||
|
||||
void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); }
|
||||
|
||||
void solenoid_dwell_minus(uint8_t solenoid_dwell) {
|
||||
if (solenoid_dwell > 0) solenoid_dwell--;
|
||||
if (solenoid_dwell > 0) solenoid_dwell--;
|
||||
}
|
||||
|
||||
void solenoid_dwell_plus(uint8_t solenoid_dwell) {
|
||||
if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++;
|
||||
if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++;
|
||||
}
|
||||
|
||||
void solenoid_set_dwell(uint8_t dwell) {
|
||||
solenoid_dwell = dwell;
|
||||
}
|
||||
void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; }
|
||||
|
||||
void solenoid_stop(void) {
|
||||
writePinLow(SOLENOID_PIN);
|
||||
solenoid_on = false;
|
||||
solenoid_buzzing = false;
|
||||
writePinLow(SOLENOID_PIN);
|
||||
solenoid_on = false;
|
||||
solenoid_buzzing = false;
|
||||
}
|
||||
|
||||
void solenoid_fire(void) {
|
||||
if (!haptic_config.buzz && solenoid_on) return;
|
||||
if (haptic_config.buzz && solenoid_buzzing) return;
|
||||
if (!haptic_config.buzz && solenoid_on) return;
|
||||
if (haptic_config.buzz && solenoid_buzzing) return;
|
||||
|
||||
solenoid_on = true;
|
||||
solenoid_buzzing = true;
|
||||
solenoid_start = timer_read();
|
||||
writePinHigh(SOLENOID_PIN);
|
||||
solenoid_on = true;
|
||||
solenoid_buzzing = true;
|
||||
solenoid_start = timer_read();
|
||||
writePinHigh(SOLENOID_PIN);
|
||||
}
|
||||
|
||||
void solenoid_check(void) {
|
||||
uint16_t elapsed = 0;
|
||||
uint16_t elapsed = 0;
|
||||
|
||||
if (!solenoid_on) return;
|
||||
if (!solenoid_on) return;
|
||||
|
||||
elapsed = timer_elapsed(solenoid_start);
|
||||
elapsed = timer_elapsed(solenoid_start);
|
||||
|
||||
//Check if it's time to finish this solenoid click cycle
|
||||
if (elapsed > solenoid_dwell) {
|
||||
solenoid_stop();
|
||||
return;
|
||||
}
|
||||
|
||||
//Check whether to buzz the solenoid on and off
|
||||
if (haptic_config.buzz) {
|
||||
if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){
|
||||
if (!solenoid_buzzing) {
|
||||
solenoid_buzzing = true;
|
||||
writePinHigh(SOLENOID_PIN);
|
||||
}
|
||||
// Check if it's time to finish this solenoid click cycle
|
||||
if (elapsed > solenoid_dwell) {
|
||||
solenoid_stop();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (solenoid_buzzing) {
|
||||
solenoid_buzzing = false;
|
||||
writePinLow(SOLENOID_PIN);
|
||||
}
|
||||
|
||||
// Check whether to buzz the solenoid on and off
|
||||
if (haptic_config.buzz) {
|
||||
if (elapsed / SOLENOID_MIN_DWELL % 2 == 0) {
|
||||
if (!solenoid_buzzing) {
|
||||
solenoid_buzzing = true;
|
||||
writePinHigh(SOLENOID_PIN);
|
||||
}
|
||||
} else {
|
||||
if (solenoid_buzzing) {
|
||||
solenoid_buzzing = false;
|
||||
writePinLow(SOLENOID_PIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void solenoid_setup(void) {
|
||||
setPinOutput(SOLENOID_PIN);
|
||||
solenoid_fire();
|
||||
setPinOutput(SOLENOID_PIN);
|
||||
solenoid_fire();
|
||||
}
|
||||
|
||||
void solenoid_shutdown(void) {
|
||||
writePinLow(SOLENOID_PIN);
|
||||
|
||||
}
|
||||
void solenoid_shutdown(void) { writePinLow(SOLENOID_PIN); }
|
||||
|
@ -18,23 +18,23 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SOLENOID_DEFAULT_DWELL
|
||||
#define SOLENOID_DEFAULT_DWELL 12
|
||||
# define SOLENOID_DEFAULT_DWELL 12
|
||||
#endif
|
||||
|
||||
#ifndef SOLENOID_MAX_DWELL
|
||||
#define SOLENOID_MAX_DWELL 100
|
||||
# define SOLENOID_MAX_DWELL 100
|
||||
#endif
|
||||
|
||||
#ifndef SOLENOID_MIN_DWELL
|
||||
#define SOLENOID_MIN_DWELL 4
|
||||
# define SOLENOID_MIN_DWELL 4
|
||||
#endif
|
||||
|
||||
#ifndef SOLENOID_ACTIVE
|
||||
#define SOLENOID_ACTIVE false
|
||||
# define SOLENOID_ACTIVE false
|
||||
#endif
|
||||
|
||||
#ifndef SOLENOID_PIN
|
||||
#define SOLENOID_PIN F6
|
||||
# define SOLENOID_PIN F6
|
||||
#endif
|
||||
|
||||
void solenoid_buzz_on(void);
|
||||
|
@ -35,68 +35,62 @@ uint8_t g_twi_transfer_buffer[20];
|
||||
// IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining.
|
||||
// If used as RGB LED driver, LEDs are assigned RGB,RGB,RGB,RGB,RGB,RGB
|
||||
uint8_t g_pwm_buffer[18];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
void IS31FL3218_write_register( uint8_t reg, uint8_t data )
|
||||
{
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
void IS31FL3218_write_register(uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
i2c_transmit(ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
}
|
||||
|
||||
void IS31FL3218_write_pwm_buffer( uint8_t *pwm_buffer )
|
||||
{
|
||||
g_twi_transfer_buffer[0] = ISSI_REG_PWM;
|
||||
for ( int i=0; i<18; i++ ) {
|
||||
g_twi_transfer_buffer[1+i] = pwm_buffer[i];
|
||||
}
|
||||
|
||||
i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT);
|
||||
void IS31FL3218_write_pwm_buffer(uint8_t *pwm_buffer) {
|
||||
g_twi_transfer_buffer[0] = ISSI_REG_PWM;
|
||||
for (int i = 0; i < 18; i++) {
|
||||
g_twi_transfer_buffer[1 + i] = pwm_buffer[i];
|
||||
}
|
||||
|
||||
i2c_transmit(ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT);
|
||||
}
|
||||
|
||||
void IS31FL3218_init(void)
|
||||
{
|
||||
// In case we ever want to reinitialize (?)
|
||||
IS31FL3218_write_register( ISSI_REG_RESET, 0x00 );
|
||||
|
||||
// Turn off software shutdown
|
||||
IS31FL3218_write_register( ISSI_REG_SHUTDOWN, 0x01 );
|
||||
void IS31FL3218_init(void) {
|
||||
// In case we ever want to reinitialize (?)
|
||||
IS31FL3218_write_register(ISSI_REG_RESET, 0x00);
|
||||
|
||||
// Set all PWM values to zero
|
||||
for ( uint8_t i = 0; i < 18; i++ ) {
|
||||
IS31FL3218_write_register( ISSI_REG_PWM+i, 0x00 );
|
||||
}
|
||||
|
||||
// Enable all channels
|
||||
for ( uint8_t i = 0; i < 3; i++ ) {
|
||||
IS31FL3218_write_register( ISSI_REG_CONTROL+i, 0b00111111 );
|
||||
}
|
||||
|
||||
// Load PWM registers and LED Control register data
|
||||
IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 );
|
||||
// Turn off software shutdown
|
||||
IS31FL3218_write_register(ISSI_REG_SHUTDOWN, 0x01);
|
||||
|
||||
// Set all PWM values to zero
|
||||
for (uint8_t i = 0; i < 18; i++) {
|
||||
IS31FL3218_write_register(ISSI_REG_PWM + i, 0x00);
|
||||
}
|
||||
|
||||
// Enable all channels
|
||||
for (uint8_t i = 0; i < 3; i++) {
|
||||
IS31FL3218_write_register(ISSI_REG_CONTROL + i, 0b00111111);
|
||||
}
|
||||
|
||||
// Load PWM registers and LED Control register data
|
||||
IS31FL3218_write_register(ISSI_REG_UPDATE, 0x01);
|
||||
}
|
||||
|
||||
void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
g_pwm_buffer[index * 3 + 0] = red;
|
||||
g_pwm_buffer[index * 3 + 1] = green;
|
||||
g_pwm_buffer[index * 3 + 2] = blue;
|
||||
g_pwm_buffer_update_required = true;
|
||||
void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
g_pwm_buffer[index * 3 + 0] = red;
|
||||
g_pwm_buffer[index * 3 + 1] = green;
|
||||
g_pwm_buffer[index * 3 + 2] = blue;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
|
||||
void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
for ( int i = 0; i < 6; i++ ) {
|
||||
IS31FL3218_set_color( i, red, green, blue );
|
||||
}
|
||||
void IS31FL3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
IS31FL3218_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3218_update_pwm_buffers(void)
|
||||
{
|
||||
if ( g_pwm_buffer_update_required ) {
|
||||
IS31FL3218_write_pwm_buffer( g_pwm_buffer );
|
||||
// Load PWM registers and LED Control register data
|
||||
IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 );
|
||||
}
|
||||
g_pwm_buffer_update_required = false;
|
||||
void IS31FL3218_update_pwm_buffers(void) {
|
||||
if (g_pwm_buffer_update_required) {
|
||||
IS31FL3218_write_pwm_buffer(g_pwm_buffer);
|
||||
// Load PWM registers and LED Control register data
|
||||
IS31FL3218_write_register(ISSI_REG_UPDATE, 0x01);
|
||||
}
|
||||
g_pwm_buffer_update_required = false;
|
||||
}
|
||||
|
@ -19,6 +19,6 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
void IS31FL3218_init(void);
|
||||
void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL3218_update_pwm_buffers(void);
|
||||
|
@ -17,11 +17,11 @@
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
# include <avr/interrupt.h>
|
||||
# include <avr/io.h>
|
||||
# include <util/delay.h>
|
||||
#else
|
||||
#include "wait.h"
|
||||
# include "wait.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
@ -41,7 +41,7 @@
|
||||
// 0b1110110 AD <-> SDA
|
||||
#define ISSI_ADDR_DEFAULT 0x74
|
||||
|
||||
#define ISSI_REG_CONFIG 0x00
|
||||
#define ISSI_REG_CONFIG 0x00
|
||||
#define ISSI_REG_CONFIG_PICTUREMODE 0x00
|
||||
#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
|
||||
#define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18
|
||||
@ -50,20 +50,20 @@
|
||||
#define ISSI_CONF_AUTOFRAMEMODE 0x04
|
||||
#define ISSI_CONF_AUDIOMODE 0x08
|
||||
|
||||
#define ISSI_REG_PICTUREFRAME 0x01
|
||||
#define ISSI_REG_PICTUREFRAME 0x01
|
||||
|
||||
#define ISSI_REG_SHUTDOWN 0x0A
|
||||
#define ISSI_REG_AUDIOSYNC 0x06
|
||||
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
#define ISSI_PERSISTENCE 0
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
@ -75,17 +75,17 @@ uint8_t g_twi_transfer_buffer[20];
|
||||
// buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[LED_DRIVER_COUNT][144];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
/* There's probably a better way to init this... */
|
||||
#if LED_DRIVER_COUNT == 1
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}};
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}};
|
||||
#elif LED_DRIVER_COUNT == 2
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}};
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}};
|
||||
#elif LED_DRIVER_COUNT == 3
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}};
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}};
|
||||
#elif LED_DRIVER_COUNT == 4
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}};
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}};
|
||||
#endif
|
||||
bool g_led_control_registers_update_required = false;
|
||||
|
||||
@ -103,20 +103,19 @@ bool g_led_control_registers_update_required = false;
|
||||
// 0x0E - R17,G15,G14,G13,G12,G11,G10,G09
|
||||
// 0x10 - R16,R15,R14,R13,R12,R11,R10,R09
|
||||
|
||||
|
||||
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) {
|
||||
break;
|
||||
}
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
@ -136,14 +135,13 @@ void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +194,6 @@ void IS31FL3731_init(uint8_t addr) {
|
||||
// most usage after initialization is just writing PWM buffers in bank 0
|
||||
// as there's not much point in double-buffering
|
||||
IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0);
|
||||
|
||||
}
|
||||
|
||||
void IS31FL3731_set_value(int index, uint8_t value) {
|
||||
@ -205,7 +202,7 @@ void IS31FL3731_set_value(int index, uint8_t value) {
|
||||
|
||||
// Subtract 0x24 to get the second index of g_pwm_buffer
|
||||
g_pwm_buffer[led.driver][led.v - 0x24] = value;
|
||||
g_pwm_buffer_update_required = true;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,10 +213,10 @@ void IS31FL3731_set_value_all(uint8_t value) {
|
||||
}
|
||||
|
||||
void IS31FL3731_set_led_control_register(uint8_t index, bool value) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
uint8_t control_register = (led.v - 0x24) / 8;
|
||||
uint8_t bit_value = (led.v - 0x24) % 8;
|
||||
uint8_t control_register = (led.v - 0x24) / 8;
|
||||
uint8_t bit_value = (led.v - 0x24) % 8;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
|
||||
@ -239,7 +236,7 @@ void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
|
||||
void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required) {
|
||||
for (int i=0; i<18; i++) {
|
||||
for (int i = 0; i < 18; i++) {
|
||||
IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IS31FL3731_DRIVER_H
|
||||
#define IS31FL3731_DRIVER_H
|
||||
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver:2;
|
||||
uint8_t v;
|
||||
uint8_t driver : 2;
|
||||
uint8_t v;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led g_is31_leds[LED_DRIVER_LED_COUNT];
|
||||
@ -44,16 +42,16 @@ void IS31FL3731_set_led_control_register(uint8_t index, bool value);
|
||||
void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
|
||||
#define C1_1 0x24
|
||||
#define C1_2 0x25
|
||||
#define C1_3 0x26
|
||||
#define C1_4 0x27
|
||||
#define C1_5 0x28
|
||||
#define C1_6 0x29
|
||||
#define C1_7 0x2A
|
||||
#define C1_8 0x2B
|
||||
#define C1_1 0x24
|
||||
#define C1_2 0x25
|
||||
#define C1_3 0x26
|
||||
#define C1_4 0x27
|
||||
#define C1_5 0x28
|
||||
#define C1_6 0x29
|
||||
#define C1_7 0x2A
|
||||
#define C1_8 0x2B
|
||||
|
||||
#define C1_9 0x2C
|
||||
#define C1_9 0x2C
|
||||
#define C1_10 0x2D
|
||||
#define C1_11 0x2E
|
||||
#define C1_12 0x2F
|
||||
@ -62,16 +60,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C1_15 0x32
|
||||
#define C1_16 0x33
|
||||
|
||||
#define C2_1 0x34
|
||||
#define C2_2 0x35
|
||||
#define C2_3 0x36
|
||||
#define C2_4 0x37
|
||||
#define C2_5 0x38
|
||||
#define C2_6 0x39
|
||||
#define C2_7 0x3A
|
||||
#define C2_8 0x3B
|
||||
#define C2_1 0x34
|
||||
#define C2_2 0x35
|
||||
#define C2_3 0x36
|
||||
#define C2_4 0x37
|
||||
#define C2_5 0x38
|
||||
#define C2_6 0x39
|
||||
#define C2_7 0x3A
|
||||
#define C2_8 0x3B
|
||||
|
||||
#define C2_9 0x3C
|
||||
#define C2_9 0x3C
|
||||
#define C2_10 0x3D
|
||||
#define C2_11 0x3E
|
||||
#define C2_12 0x3F
|
||||
@ -80,16 +78,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C2_15 0x42
|
||||
#define C2_16 0x43
|
||||
|
||||
#define C3_1 0x44
|
||||
#define C3_2 0x45
|
||||
#define C3_3 0x46
|
||||
#define C3_4 0x47
|
||||
#define C3_5 0x48
|
||||
#define C3_6 0x49
|
||||
#define C3_7 0x4A
|
||||
#define C3_8 0x4B
|
||||
#define C3_1 0x44
|
||||
#define C3_2 0x45
|
||||
#define C3_3 0x46
|
||||
#define C3_4 0x47
|
||||
#define C3_5 0x48
|
||||
#define C3_6 0x49
|
||||
#define C3_7 0x4A
|
||||
#define C3_8 0x4B
|
||||
|
||||
#define C3_9 0x4C
|
||||
#define C3_9 0x4C
|
||||
#define C3_10 0x4D
|
||||
#define C3_11 0x4E
|
||||
#define C3_12 0x4F
|
||||
@ -98,16 +96,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C3_15 0x52
|
||||
#define C3_16 0x53
|
||||
|
||||
#define C4_1 0x54
|
||||
#define C4_2 0x55
|
||||
#define C4_3 0x56
|
||||
#define C4_4 0x57
|
||||
#define C4_5 0x58
|
||||
#define C4_6 0x59
|
||||
#define C4_7 0x5A
|
||||
#define C4_8 0x5B
|
||||
#define C4_1 0x54
|
||||
#define C4_2 0x55
|
||||
#define C4_3 0x56
|
||||
#define C4_4 0x57
|
||||
#define C4_5 0x58
|
||||
#define C4_6 0x59
|
||||
#define C4_7 0x5A
|
||||
#define C4_8 0x5B
|
||||
|
||||
#define C4_9 0x5C
|
||||
#define C4_9 0x5C
|
||||
#define C4_10 0x5D
|
||||
#define C4_11 0x5E
|
||||
#define C4_12 0x5F
|
||||
@ -116,16 +114,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C4_15 0x62
|
||||
#define C4_16 0x63
|
||||
|
||||
#define C5_1 0x64
|
||||
#define C5_2 0x65
|
||||
#define C5_3 0x66
|
||||
#define C5_4 0x67
|
||||
#define C5_5 0x68
|
||||
#define C5_6 0x69
|
||||
#define C5_7 0x6A
|
||||
#define C5_8 0x6B
|
||||
#define C5_1 0x64
|
||||
#define C5_2 0x65
|
||||
#define C5_3 0x66
|
||||
#define C5_4 0x67
|
||||
#define C5_5 0x68
|
||||
#define C5_6 0x69
|
||||
#define C5_7 0x6A
|
||||
#define C5_8 0x6B
|
||||
|
||||
#define C5_9 0x6C
|
||||
#define C5_9 0x6C
|
||||
#define C5_10 0x6D
|
||||
#define C5_11 0x6E
|
||||
#define C5_12 0x6F
|
||||
@ -134,16 +132,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C5_15 0x72
|
||||
#define C5_16 0x73
|
||||
|
||||
#define C6_1 0x74
|
||||
#define C6_2 0x75
|
||||
#define C6_3 0x76
|
||||
#define C6_4 0x77
|
||||
#define C6_5 0x78
|
||||
#define C6_6 0x79
|
||||
#define C6_7 0x7A
|
||||
#define C6_8 0x7B
|
||||
#define C6_1 0x74
|
||||
#define C6_2 0x75
|
||||
#define C6_3 0x76
|
||||
#define C6_4 0x77
|
||||
#define C6_5 0x78
|
||||
#define C6_6 0x79
|
||||
#define C6_7 0x7A
|
||||
#define C6_8 0x7B
|
||||
|
||||
#define C6_9 0x7C
|
||||
#define C6_9 0x7C
|
||||
#define C6_10 0x7D
|
||||
#define C6_11 0x7E
|
||||
#define C6_12 0x7F
|
||||
@ -152,16 +150,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C6_15 0x82
|
||||
#define C6_16 0x83
|
||||
|
||||
#define C7_1 0x84
|
||||
#define C7_2 0x85
|
||||
#define C7_3 0x86
|
||||
#define C7_4 0x87
|
||||
#define C7_5 0x88
|
||||
#define C7_6 0x89
|
||||
#define C7_7 0x8A
|
||||
#define C7_8 0x8B
|
||||
#define C7_1 0x84
|
||||
#define C7_2 0x85
|
||||
#define C7_3 0x86
|
||||
#define C7_4 0x87
|
||||
#define C7_5 0x88
|
||||
#define C7_6 0x89
|
||||
#define C7_7 0x8A
|
||||
#define C7_8 0x8B
|
||||
|
||||
#define C7_9 0x8C
|
||||
#define C7_9 0x8C
|
||||
#define C7_10 0x8D
|
||||
#define C7_11 0x8E
|
||||
#define C7_12 0x8F
|
||||
@ -170,16 +168,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C7_15 0x92
|
||||
#define C7_16 0x93
|
||||
|
||||
#define C8_1 0x94
|
||||
#define C8_2 0x95
|
||||
#define C8_3 0x96
|
||||
#define C8_4 0x97
|
||||
#define C8_5 0x98
|
||||
#define C8_6 0x99
|
||||
#define C8_7 0x9A
|
||||
#define C8_8 0x9B
|
||||
#define C8_1 0x94
|
||||
#define C8_2 0x95
|
||||
#define C8_3 0x96
|
||||
#define C8_4 0x97
|
||||
#define C8_5 0x98
|
||||
#define C8_6 0x99
|
||||
#define C8_7 0x9A
|
||||
#define C8_8 0x9B
|
||||
|
||||
#define C8_9 0x9C
|
||||
#define C8_9 0x9C
|
||||
#define C8_10 0x9D
|
||||
#define C8_11 0x9E
|
||||
#define C8_12 0x9F
|
||||
@ -188,16 +186,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C8_15 0xA2
|
||||
#define C8_16 0xA3
|
||||
|
||||
#define C9_1 0xA4
|
||||
#define C9_2 0xA5
|
||||
#define C9_3 0xA6
|
||||
#define C9_4 0xA7
|
||||
#define C9_5 0xA8
|
||||
#define C9_6 0xA9
|
||||
#define C9_7 0xAA
|
||||
#define C9_8 0xAB
|
||||
#define C9_1 0xA4
|
||||
#define C9_2 0xA5
|
||||
#define C9_3 0xA6
|
||||
#define C9_4 0xA7
|
||||
#define C9_5 0xA8
|
||||
#define C9_6 0xA9
|
||||
#define C9_7 0xAA
|
||||
#define C9_8 0xAB
|
||||
|
||||
#define C9_9 0xAC
|
||||
#define C9_9 0xAC
|
||||
#define C9_10 0xAD
|
||||
#define C9_11 0xAE
|
||||
#define C9_12 0xAF
|
||||
@ -206,5 +204,4 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
#define C9_15 0xB2
|
||||
#define C9_16 0xB3
|
||||
|
||||
|
||||
#endif // IS31FL3731_DRIVER_H
|
||||
#endif // IS31FL3731_DRIVER_H
|
||||
|
@ -16,11 +16,11 @@
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
# include <avr/interrupt.h>
|
||||
# include <avr/io.h>
|
||||
# include <util/delay.h>
|
||||
#else
|
||||
#include "wait.h"
|
||||
# include "wait.h"
|
||||
#endif
|
||||
|
||||
#include "is31fl3731.h"
|
||||
@ -37,7 +37,7 @@
|
||||
// 0b1110110 AD <-> SDA
|
||||
#define ISSI_ADDR_DEFAULT 0x74
|
||||
|
||||
#define ISSI_REG_CONFIG 0x00
|
||||
#define ISSI_REG_CONFIG 0x00
|
||||
#define ISSI_REG_CONFIG_PICTUREMODE 0x00
|
||||
#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
|
||||
#define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18
|
||||
@ -46,20 +46,20 @@
|
||||
#define ISSI_CONF_AUTOFRAMEMODE 0x04
|
||||
#define ISSI_CONF_AUDIOMODE 0x08
|
||||
|
||||
#define ISSI_REG_PICTUREFRAME 0x01
|
||||
#define ISSI_REG_PICTUREFRAME 0x01
|
||||
|
||||
#define ISSI_REG_SHUTDOWN 0x0A
|
||||
#define ISSI_REG_AUDIOSYNC 0x06
|
||||
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
#define ISSI_PERSISTENCE 0
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
@ -71,10 +71,10 @@ uint8_t g_twi_transfer_buffer[20];
|
||||
// buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[DRIVER_COUNT][144];
|
||||
bool g_pwm_buffer_update_required[DRIVER_COUNT] = { false };
|
||||
bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][18] = { { 0 }, { 0 } };
|
||||
bool g_led_control_registers_update_required[DRIVER_COUNT] = { false };
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][18] = {{0}, {0}};
|
||||
bool g_led_control_registers_update_required[DRIVER_COUNT] = {false};
|
||||
|
||||
// This is the bit pattern in the LED control registers
|
||||
// (for matrix A, add one to register for matrix B)
|
||||
@ -90,179 +90,159 @@ bool g_led_control_registers_update_required[DRIVER_COUNT] = { false };
|
||||
// 0x0E - R17,G15,G14,G13,G12,G11,G10,G09
|
||||
// 0x10 - R16,R15,R14,R13,R12,R11,R10,R09
|
||||
|
||||
|
||||
void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data )
|
||||
{
|
||||
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
{
|
||||
void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes bank is already selected
|
||||
|
||||
// transmit PWM registers in 9 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for ( int i = 0; i < 144; i += 16 ) {
|
||||
for (int i = 0; i < 144; i += 16) {
|
||||
// set the first register, e.g. 0x24, 0x34, 0x44, etc.
|
||||
g_twi_transfer_buffer[0] = 0x24 + i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer
|
||||
for ( int j = 0; j < 16; j++ ) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3731_init( uint8_t addr )
|
||||
{
|
||||
void IS31FL3731_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, first enable software shutdown,
|
||||
// then set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// select "function register" bank
|
||||
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );
|
||||
IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG);
|
||||
|
||||
// enable software shutdown
|
||||
IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x00 );
|
||||
// this delay was copied from other drivers, might not be needed
|
||||
#ifdef __AVR__
|
||||
_delay_ms( 10 );
|
||||
#else
|
||||
IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00);
|
||||
// this delay was copied from other drivers, might not be needed
|
||||
#ifdef __AVR__
|
||||
_delay_ms(10);
|
||||
#else
|
||||
wait_ms(10);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// picture mode
|
||||
IS31FL3731_write_register( addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE );
|
||||
IS31FL3731_write_register(addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE);
|
||||
// display frame 0
|
||||
IS31FL3731_write_register( addr, ISSI_REG_PICTUREFRAME, 0x00 );
|
||||
IS31FL3731_write_register(addr, ISSI_REG_PICTUREFRAME, 0x00);
|
||||
// audio sync off
|
||||
IS31FL3731_write_register( addr, ISSI_REG_AUDIOSYNC, 0x00 );
|
||||
IS31FL3731_write_register(addr, ISSI_REG_AUDIOSYNC, 0x00);
|
||||
|
||||
// select bank 0
|
||||
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 );
|
||||
IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0);
|
||||
|
||||
// turn off all LEDs in the LED control register
|
||||
for ( int i = 0x00; i <= 0x11; i++ )
|
||||
{
|
||||
IS31FL3731_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0x11; i++) {
|
||||
IS31FL3731_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// turn off all LEDs in the blink control register (not really needed)
|
||||
for ( int i = 0x12; i <= 0x23; i++ )
|
||||
{
|
||||
IS31FL3731_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x12; i <= 0x23; i++) {
|
||||
IS31FL3731_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// set PWM on all LEDs to 0
|
||||
for ( int i = 0x24; i <= 0xB3; i++ )
|
||||
{
|
||||
IS31FL3731_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x24; i <= 0xB3; i++) {
|
||||
IS31FL3731_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// select "function register" bank
|
||||
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );
|
||||
IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG);
|
||||
|
||||
// disable software shutdown
|
||||
IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x01 );
|
||||
IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x01);
|
||||
|
||||
// select bank 0 and leave it selected.
|
||||
// most usage after initialization is just writing PWM buffers in bank 0
|
||||
// as there's not much point in double-buffering
|
||||
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 );
|
||||
|
||||
IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0);
|
||||
}
|
||||
|
||||
void IS31FL3731_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
|
||||
void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
// Subtract 0x24 to get the second index of g_pwm_buffer
|
||||
g_pwm_buffer[led.driver][led.r - 0x24] = red;
|
||||
g_pwm_buffer[led.driver][led.g - 0x24] = green;
|
||||
g_pwm_buffer[led.driver][led.b - 0x24] = blue;
|
||||
g_pwm_buffer[led.driver][led.r - 0x24] = red;
|
||||
g_pwm_buffer[led.driver][led.g - 0x24] = green;
|
||||
g_pwm_buffer[led.driver][led.b - 0x24] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
|
||||
{
|
||||
IS31FL3731_set_color( i, red, green, blue );
|
||||
void IS31FL3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL3731_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
|
||||
{
|
||||
void IS31FL3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
uint8_t control_register_r = (led.r - 0x24) / 8;
|
||||
uint8_t control_register_g = (led.g - 0x24) / 8;
|
||||
uint8_t control_register_b = (led.b - 0x24) / 8;
|
||||
uint8_t bit_r = (led.r - 0x24) % 8;
|
||||
uint8_t bit_g = (led.g - 0x24) % 8;
|
||||
uint8_t bit_b = (led.b - 0x24) % 8;
|
||||
uint8_t bit_r = (led.r - 0x24) % 8;
|
||||
uint8_t bit_g = (led.g - 0x24) % 8;
|
||||
uint8_t bit_b = (led.b - 0x24) % 8;
|
||||
|
||||
if ( red ) {
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if ( green ) {
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if ( blue ) {
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
|
||||
}
|
||||
|
||||
void IS31FL3731_update_pwm_buffers( uint8_t addr, uint8_t index )
|
||||
{
|
||||
if ( g_pwm_buffer_update_required[index] )
|
||||
{
|
||||
IS31FL3731_write_pwm_buffer( addr, g_pwm_buffer[index] );
|
||||
void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
IS31FL3731_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
|
||||
void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index )
|
||||
{
|
||||
if ( g_led_control_registers_update_required[index] )
|
||||
{
|
||||
for ( int i=0; i<18; i++ )
|
||||
{
|
||||
IS31FL3731_write_register( addr, i, g_led_control_registers[index][i] );
|
||||
void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
for (int i = 0; i < 18; i++) {
|
||||
IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IS31FL3731_DRIVER_H
|
||||
#define IS31FL3731_DRIVER_H
|
||||
|
||||
@ -23,40 +22,40 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver:2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t driver : 2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL3731_init( uint8_t addr );
|
||||
void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data );
|
||||
void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
|
||||
void IS31FL3731_init(uint8_t addr);
|
||||
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
|
||||
void IS31FL3731_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
|
||||
void IS31FL3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void IS31FL3731_update_pwm_buffers( uint8_t addr, uint8_t index );
|
||||
void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
|
||||
#define C1_1 0x24
|
||||
#define C1_2 0x25
|
||||
#define C1_3 0x26
|
||||
#define C1_4 0x27
|
||||
#define C1_5 0x28
|
||||
#define C1_6 0x29
|
||||
#define C1_7 0x2A
|
||||
#define C1_8 0x2B
|
||||
#define C1_1 0x24
|
||||
#define C1_2 0x25
|
||||
#define C1_3 0x26
|
||||
#define C1_4 0x27
|
||||
#define C1_5 0x28
|
||||
#define C1_6 0x29
|
||||
#define C1_7 0x2A
|
||||
#define C1_8 0x2B
|
||||
|
||||
#define C1_9 0x2C
|
||||
#define C1_9 0x2C
|
||||
#define C1_10 0x2D
|
||||
#define C1_11 0x2E
|
||||
#define C1_12 0x2F
|
||||
@ -65,16 +64,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C1_15 0x32
|
||||
#define C1_16 0x33
|
||||
|
||||
#define C2_1 0x34
|
||||
#define C2_2 0x35
|
||||
#define C2_3 0x36
|
||||
#define C2_4 0x37
|
||||
#define C2_5 0x38
|
||||
#define C2_6 0x39
|
||||
#define C2_7 0x3A
|
||||
#define C2_8 0x3B
|
||||
#define C2_1 0x34
|
||||
#define C2_2 0x35
|
||||
#define C2_3 0x36
|
||||
#define C2_4 0x37
|
||||
#define C2_5 0x38
|
||||
#define C2_6 0x39
|
||||
#define C2_7 0x3A
|
||||
#define C2_8 0x3B
|
||||
|
||||
#define C2_9 0x3C
|
||||
#define C2_9 0x3C
|
||||
#define C2_10 0x3D
|
||||
#define C2_11 0x3E
|
||||
#define C2_12 0x3F
|
||||
@ -83,16 +82,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C2_15 0x42
|
||||
#define C2_16 0x43
|
||||
|
||||
#define C3_1 0x44
|
||||
#define C3_2 0x45
|
||||
#define C3_3 0x46
|
||||
#define C3_4 0x47
|
||||
#define C3_5 0x48
|
||||
#define C3_6 0x49
|
||||
#define C3_7 0x4A
|
||||
#define C3_8 0x4B
|
||||
#define C3_1 0x44
|
||||
#define C3_2 0x45
|
||||
#define C3_3 0x46
|
||||
#define C3_4 0x47
|
||||
#define C3_5 0x48
|
||||
#define C3_6 0x49
|
||||
#define C3_7 0x4A
|
||||
#define C3_8 0x4B
|
||||
|
||||
#define C3_9 0x4C
|
||||
#define C3_9 0x4C
|
||||
#define C3_10 0x4D
|
||||
#define C3_11 0x4E
|
||||
#define C3_12 0x4F
|
||||
@ -101,16 +100,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C3_15 0x52
|
||||
#define C3_16 0x53
|
||||
|
||||
#define C4_1 0x54
|
||||
#define C4_2 0x55
|
||||
#define C4_3 0x56
|
||||
#define C4_4 0x57
|
||||
#define C4_5 0x58
|
||||
#define C4_6 0x59
|
||||
#define C4_7 0x5A
|
||||
#define C4_8 0x5B
|
||||
#define C4_1 0x54
|
||||
#define C4_2 0x55
|
||||
#define C4_3 0x56
|
||||
#define C4_4 0x57
|
||||
#define C4_5 0x58
|
||||
#define C4_6 0x59
|
||||
#define C4_7 0x5A
|
||||
#define C4_8 0x5B
|
||||
|
||||
#define C4_9 0x5C
|
||||
#define C4_9 0x5C
|
||||
#define C4_10 0x5D
|
||||
#define C4_11 0x5E
|
||||
#define C4_12 0x5F
|
||||
@ -119,16 +118,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C4_15 0x62
|
||||
#define C4_16 0x63
|
||||
|
||||
#define C5_1 0x64
|
||||
#define C5_2 0x65
|
||||
#define C5_3 0x66
|
||||
#define C5_4 0x67
|
||||
#define C5_5 0x68
|
||||
#define C5_6 0x69
|
||||
#define C5_7 0x6A
|
||||
#define C5_8 0x6B
|
||||
#define C5_1 0x64
|
||||
#define C5_2 0x65
|
||||
#define C5_3 0x66
|
||||
#define C5_4 0x67
|
||||
#define C5_5 0x68
|
||||
#define C5_6 0x69
|
||||
#define C5_7 0x6A
|
||||
#define C5_8 0x6B
|
||||
|
||||
#define C5_9 0x6C
|
||||
#define C5_9 0x6C
|
||||
#define C5_10 0x6D
|
||||
#define C5_11 0x6E
|
||||
#define C5_12 0x6F
|
||||
@ -137,16 +136,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C5_15 0x72
|
||||
#define C5_16 0x73
|
||||
|
||||
#define C6_1 0x74
|
||||
#define C6_2 0x75
|
||||
#define C6_3 0x76
|
||||
#define C6_4 0x77
|
||||
#define C6_5 0x78
|
||||
#define C6_6 0x79
|
||||
#define C6_7 0x7A
|
||||
#define C6_8 0x7B
|
||||
#define C6_1 0x74
|
||||
#define C6_2 0x75
|
||||
#define C6_3 0x76
|
||||
#define C6_4 0x77
|
||||
#define C6_5 0x78
|
||||
#define C6_6 0x79
|
||||
#define C6_7 0x7A
|
||||
#define C6_8 0x7B
|
||||
|
||||
#define C6_9 0x7C
|
||||
#define C6_9 0x7C
|
||||
#define C6_10 0x7D
|
||||
#define C6_11 0x7E
|
||||
#define C6_12 0x7F
|
||||
@ -155,16 +154,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C6_15 0x82
|
||||
#define C6_16 0x83
|
||||
|
||||
#define C7_1 0x84
|
||||
#define C7_2 0x85
|
||||
#define C7_3 0x86
|
||||
#define C7_4 0x87
|
||||
#define C7_5 0x88
|
||||
#define C7_6 0x89
|
||||
#define C7_7 0x8A
|
||||
#define C7_8 0x8B
|
||||
#define C7_1 0x84
|
||||
#define C7_2 0x85
|
||||
#define C7_3 0x86
|
||||
#define C7_4 0x87
|
||||
#define C7_5 0x88
|
||||
#define C7_6 0x89
|
||||
#define C7_7 0x8A
|
||||
#define C7_8 0x8B
|
||||
|
||||
#define C7_9 0x8C
|
||||
#define C7_9 0x8C
|
||||
#define C7_10 0x8D
|
||||
#define C7_11 0x8E
|
||||
#define C7_12 0x8F
|
||||
@ -173,16 +172,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C7_15 0x92
|
||||
#define C7_16 0x93
|
||||
|
||||
#define C8_1 0x94
|
||||
#define C8_2 0x95
|
||||
#define C8_3 0x96
|
||||
#define C8_4 0x97
|
||||
#define C8_5 0x98
|
||||
#define C8_6 0x99
|
||||
#define C8_7 0x9A
|
||||
#define C8_8 0x9B
|
||||
#define C8_1 0x94
|
||||
#define C8_2 0x95
|
||||
#define C8_3 0x96
|
||||
#define C8_4 0x97
|
||||
#define C8_5 0x98
|
||||
#define C8_6 0x99
|
||||
#define C8_7 0x9A
|
||||
#define C8_8 0x9B
|
||||
|
||||
#define C8_9 0x9C
|
||||
#define C8_9 0x9C
|
||||
#define C8_10 0x9D
|
||||
#define C8_11 0x9E
|
||||
#define C8_12 0x9F
|
||||
@ -191,16 +190,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C8_15 0xA2
|
||||
#define C8_16 0xA3
|
||||
|
||||
#define C9_1 0xA4
|
||||
#define C9_2 0xA5
|
||||
#define C9_3 0xA6
|
||||
#define C9_4 0xA7
|
||||
#define C9_5 0xA8
|
||||
#define C9_6 0xA9
|
||||
#define C9_7 0xAA
|
||||
#define C9_8 0xAB
|
||||
#define C9_1 0xA4
|
||||
#define C9_2 0xA5
|
||||
#define C9_3 0xA6
|
||||
#define C9_4 0xA7
|
||||
#define C9_5 0xA8
|
||||
#define C9_6 0xA9
|
||||
#define C9_7 0xAA
|
||||
#define C9_8 0xAB
|
||||
|
||||
#define C9_9 0xAC
|
||||
#define C9_9 0xAC
|
||||
#define C9_10 0xAD
|
||||
#define C9_11 0xAE
|
||||
#define C9_12 0xAF
|
||||
@ -209,6 +208,4 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
#define C9_15 0xB2
|
||||
#define C9_16 0xB3
|
||||
|
||||
|
||||
|
||||
#endif // IS31FL3731_DRIVER_H
|
||||
#endif // IS31FL3731_DRIVER_H
|
||||
|
@ -17,11 +17,11 @@
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
# include <avr/interrupt.h>
|
||||
# include <avr/io.h>
|
||||
# include <util/delay.h>
|
||||
#else
|
||||
#include "wait.h"
|
||||
# include "wait.h"
|
||||
#endif
|
||||
|
||||
#include "is31fl3733.h"
|
||||
@ -46,23 +46,23 @@
|
||||
#define ISSI_INTERRUPTMASKREGISTER 0xF0
|
||||
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
|
||||
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
|
||||
#define ISSI_PAGE_PWM 0x01 //PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 //PG3
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
|
||||
#define ISSI_PAGE_PWM 0x01 // PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 // PG3
|
||||
|
||||
#define ISSI_REG_CONFIGURATION 0x00 //PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
|
||||
#define ISSI_REG_RESET 0x11// PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F //PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 //PG3
|
||||
#define ISSI_REG_CONFIGURATION 0x00 // PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
|
||||
#define ISSI_REG_RESET 0x11 // PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F // PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 // PG3
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
#define ISSI_PERSISTENCE 0
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
@ -75,56 +75,51 @@ uint8_t g_twi_transfer_buffer[20];
|
||||
// buffers and the transfers in IS31FL3733_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
|
||||
bool g_pwm_buffer_update_required[DRIVER_COUNT] = { false };
|
||||
bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 }, { 0 } };
|
||||
bool g_led_control_registers_update_required[DRIVER_COUNT] = { false };
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}};
|
||||
bool g_led_control_registers_update_required[DRIVER_COUNT] = {false};
|
||||
|
||||
void IS31FL3733_write_register( uint8_t addr, uint8_t reg, uint8_t data )
|
||||
{
|
||||
void IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3733_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
{
|
||||
void IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for ( int i = 0; i < 192; i += 16 ) {
|
||||
for (int i = 0; i < 192; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
for ( int j = 0; j < 16; j++ ) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3733_init( uint8_t addr, uint8_t sync)
|
||||
{
|
||||
void IS31FL3733_init(uint8_t addr, uint8_t sync) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
@ -132,120 +127,108 @@ void IS31FL3733_init( uint8_t addr, uint8_t sync)
|
||||
// Sync is passed so set it according to the datasheet.
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG0
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
// Turn off all LEDs.
|
||||
for ( int i = 0x00; i <= 0x17; i++ )
|
||||
{
|
||||
IS31FL3733_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0x17; i++) {
|
||||
IS31FL3733_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG1
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for ( int i = 0x00; i <= 0xBF; i++ )
|
||||
{
|
||||
IS31FL3733_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0xBF; i++) {
|
||||
IS31FL3733_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG3
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
|
||||
// Set global current to maximum.
|
||||
IS31FL3733_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
|
||||
IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
|
||||
// Disable software shutdown.
|
||||
IS31FL3733_write_register( addr, ISSI_REG_CONFIGURATION, (sync << 6) | 0x01 );
|
||||
IS31FL3733_write_register(addr, ISSI_REG_CONFIGURATION, (sync << 6) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms( 10 );
|
||||
#else
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms(10);
|
||||
#else
|
||||
wait_ms(10);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3733_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
|
||||
void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3733_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
|
||||
{
|
||||
IS31FL3733_set_color( i, red, green, blue );
|
||||
void IS31FL3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL3733_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3733_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
|
||||
{
|
||||
void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if ( red ) {
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if ( green ) {
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if ( blue ) {
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
|
||||
}
|
||||
|
||||
void IS31FL3733_update_pwm_buffers( uint8_t addr, uint8_t index )
|
||||
{
|
||||
if ( g_pwm_buffer_update_required[index] )
|
||||
{
|
||||
void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
|
||||
IS31FL3733_write_pwm_buffer( addr, g_pwm_buffer[index] );
|
||||
IS31FL3733_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
|
||||
void IS31FL3733_update_led_control_registers( uint8_t addr, uint8_t index )
|
||||
{
|
||||
if ( g_led_control_registers_update_required[index] )
|
||||
{
|
||||
void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
for ( int i=0; i<24; i++ )
|
||||
{
|
||||
IS31FL3733_write_register(addr, i, g_led_control_registers[index][i] );
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
for (int i = 0; i < 24; i++) {
|
||||
IS31FL3733_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
|
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IS31FL3733_DRIVER_H
|
||||
#define IS31FL3733_DRIVER_H
|
||||
|
||||
@ -24,232 +23,232 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver:2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t driver : 2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL3733_init( uint8_t addr, uint8_t sync );
|
||||
void IS31FL3733_write_register( uint8_t addr, uint8_t reg, uint8_t data );
|
||||
void IS31FL3733_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
|
||||
void IS31FL3733_init(uint8_t addr, uint8_t sync);
|
||||
void IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
|
||||
void IS31FL3733_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3733_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void IS31FL3733_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
|
||||
void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void IS31FL3733_update_pwm_buffers( uint8_t addr, uint8_t index );
|
||||
void IS31FL3733_update_led_control_registers( uint8_t addr, uint8_t index );
|
||||
void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x06
|
||||
#define A_8 0x07
|
||||
#define A_9 0x08
|
||||
#define A_10 0x09
|
||||
#define A_11 0x0A
|
||||
#define A_12 0x0B
|
||||
#define A_13 0x0C
|
||||
#define A_14 0x0D
|
||||
#define A_15 0x0E
|
||||
#define A_16 0x0F
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x06
|
||||
#define A_8 0x07
|
||||
#define A_9 0x08
|
||||
#define A_10 0x09
|
||||
#define A_11 0x0A
|
||||
#define A_12 0x0B
|
||||
#define A_13 0x0C
|
||||
#define A_14 0x0D
|
||||
#define A_15 0x0E
|
||||
#define A_16 0x0F
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x16
|
||||
#define B_8 0x17
|
||||
#define B_9 0x18
|
||||
#define B_10 0x19
|
||||
#define B_11 0x1A
|
||||
#define B_12 0x1B
|
||||
#define B_13 0x1C
|
||||
#define B_14 0x1D
|
||||
#define B_15 0x1E
|
||||
#define B_16 0x1F
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x16
|
||||
#define B_8 0x17
|
||||
#define B_9 0x18
|
||||
#define B_10 0x19
|
||||
#define B_11 0x1A
|
||||
#define B_12 0x1B
|
||||
#define B_13 0x1C
|
||||
#define B_14 0x1D
|
||||
#define B_15 0x1E
|
||||
#define B_16 0x1F
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x26
|
||||
#define C_8 0x27
|
||||
#define C_9 0x28
|
||||
#define C_10 0x29
|
||||
#define C_11 0x2A
|
||||
#define C_12 0x2B
|
||||
#define C_13 0x2C
|
||||
#define C_14 0x2D
|
||||
#define C_15 0x2E
|
||||
#define C_16 0x2F
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x26
|
||||
#define C_8 0x27
|
||||
#define C_9 0x28
|
||||
#define C_10 0x29
|
||||
#define C_11 0x2A
|
||||
#define C_12 0x2B
|
||||
#define C_13 0x2C
|
||||
#define C_14 0x2D
|
||||
#define C_15 0x2E
|
||||
#define C_16 0x2F
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x36
|
||||
#define D_8 0x37
|
||||
#define D_9 0x38
|
||||
#define D_10 0x39
|
||||
#define D_11 0x3A
|
||||
#define D_12 0x3B
|
||||
#define D_13 0x3C
|
||||
#define D_14 0x3D
|
||||
#define D_15 0x3E
|
||||
#define D_16 0x3F
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x36
|
||||
#define D_8 0x37
|
||||
#define D_9 0x38
|
||||
#define D_10 0x39
|
||||
#define D_11 0x3A
|
||||
#define D_12 0x3B
|
||||
#define D_13 0x3C
|
||||
#define D_14 0x3D
|
||||
#define D_15 0x3E
|
||||
#define D_16 0x3F
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x46
|
||||
#define E_8 0x47
|
||||
#define E_9 0x48
|
||||
#define E_10 0x49
|
||||
#define E_11 0x4A
|
||||
#define E_12 0x4B
|
||||
#define E_13 0x4C
|
||||
#define E_14 0x4D
|
||||
#define E_15 0x4E
|
||||
#define E_16 0x4F
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x46
|
||||
#define E_8 0x47
|
||||
#define E_9 0x48
|
||||
#define E_10 0x49
|
||||
#define E_11 0x4A
|
||||
#define E_12 0x4B
|
||||
#define E_13 0x4C
|
||||
#define E_14 0x4D
|
||||
#define E_15 0x4E
|
||||
#define E_16 0x4F
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x56
|
||||
#define F_8 0x57
|
||||
#define F_9 0x58
|
||||
#define F_10 0x59
|
||||
#define F_11 0x5A
|
||||
#define F_12 0x5B
|
||||
#define F_13 0x5C
|
||||
#define F_14 0x5D
|
||||
#define F_15 0x5E
|
||||
#define F_16 0x5F
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x56
|
||||
#define F_8 0x57
|
||||
#define F_9 0x58
|
||||
#define F_10 0x59
|
||||
#define F_11 0x5A
|
||||
#define F_12 0x5B
|
||||
#define F_13 0x5C
|
||||
#define F_14 0x5D
|
||||
#define F_15 0x5E
|
||||
#define F_16 0x5F
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x66
|
||||
#define G_8 0x67
|
||||
#define G_9 0x68
|
||||
#define G_10 0x69
|
||||
#define G_11 0x6A
|
||||
#define G_12 0x6B
|
||||
#define G_13 0x6C
|
||||
#define G_14 0x6D
|
||||
#define G_15 0x6E
|
||||
#define G_16 0x6F
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x66
|
||||
#define G_8 0x67
|
||||
#define G_9 0x68
|
||||
#define G_10 0x69
|
||||
#define G_11 0x6A
|
||||
#define G_12 0x6B
|
||||
#define G_13 0x6C
|
||||
#define G_14 0x6D
|
||||
#define G_15 0x6E
|
||||
#define G_16 0x6F
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x76
|
||||
#define H_8 0x77
|
||||
#define H_9 0x78
|
||||
#define H_10 0x79
|
||||
#define H_11 0x7A
|
||||
#define H_12 0x7B
|
||||
#define H_13 0x7C
|
||||
#define H_14 0x7D
|
||||
#define H_15 0x7E
|
||||
#define H_16 0x7F
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x76
|
||||
#define H_8 0x77
|
||||
#define H_9 0x78
|
||||
#define H_10 0x79
|
||||
#define H_11 0x7A
|
||||
#define H_12 0x7B
|
||||
#define H_13 0x7C
|
||||
#define H_14 0x7D
|
||||
#define H_15 0x7E
|
||||
#define H_16 0x7F
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x86
|
||||
#define I_8 0x87
|
||||
#define I_9 0x88
|
||||
#define I_10 0x89
|
||||
#define I_11 0x8A
|
||||
#define I_12 0x8B
|
||||
#define I_13 0x8C
|
||||
#define I_14 0x8D
|
||||
#define I_15 0x8E
|
||||
#define I_16 0x8F
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x86
|
||||
#define I_8 0x87
|
||||
#define I_9 0x88
|
||||
#define I_10 0x89
|
||||
#define I_11 0x8A
|
||||
#define I_12 0x8B
|
||||
#define I_13 0x8C
|
||||
#define I_14 0x8D
|
||||
#define I_15 0x8E
|
||||
#define I_16 0x8F
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x96
|
||||
#define J_8 0x97
|
||||
#define J_9 0x98
|
||||
#define J_10 0x99
|
||||
#define J_11 0x9A
|
||||
#define J_12 0x9B
|
||||
#define J_13 0x9C
|
||||
#define J_14 0x9D
|
||||
#define J_15 0x9E
|
||||
#define J_16 0x9F
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x96
|
||||
#define J_8 0x97
|
||||
#define J_9 0x98
|
||||
#define J_10 0x99
|
||||
#define J_11 0x9A
|
||||
#define J_12 0x9B
|
||||
#define J_13 0x9C
|
||||
#define J_14 0x9D
|
||||
#define J_15 0x9E
|
||||
#define J_16 0x9F
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA6
|
||||
#define K_8 0xA7
|
||||
#define K_9 0xA8
|
||||
#define K_10 0xA9
|
||||
#define K_11 0xAA
|
||||
#define K_12 0xAB
|
||||
#define K_13 0xAC
|
||||
#define K_14 0xAD
|
||||
#define K_15 0xAE
|
||||
#define K_16 0xAF
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA6
|
||||
#define K_8 0xA7
|
||||
#define K_9 0xA8
|
||||
#define K_10 0xA9
|
||||
#define K_11 0xAA
|
||||
#define K_12 0xAB
|
||||
#define K_13 0xAC
|
||||
#define K_14 0xAD
|
||||
#define K_15 0xAE
|
||||
#define K_16 0xAF
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB6
|
||||
#define L_8 0xB7
|
||||
#define L_9 0xB8
|
||||
#define L_10 0xB9
|
||||
#define L_11 0xBA
|
||||
#define L_12 0xBB
|
||||
#define L_13 0xBC
|
||||
#define L_14 0xBD
|
||||
#define L_15 0xBE
|
||||
#define L_16 0xBF
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB6
|
||||
#define L_8 0xB7
|
||||
#define L_9 0xB8
|
||||
#define L_10 0xB9
|
||||
#define L_11 0xBA
|
||||
#define L_12 0xBB
|
||||
#define L_13 0xBC
|
||||
#define L_14 0xBD
|
||||
#define L_15 0xBE
|
||||
#define L_16 0xBF
|
||||
|
||||
#endif // IS31FL3733_DRIVER_H
|
||||
#endif // IS31FL3733_DRIVER_H
|
||||
|
@ -14,13 +14,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
# include <avr/interrupt.h>
|
||||
# include <avr/io.h>
|
||||
# include <util/delay.h>
|
||||
#else
|
||||
#include "wait.h"
|
||||
# include "wait.h"
|
||||
#endif
|
||||
|
||||
#include "is31fl3736.h"
|
||||
@ -28,8 +27,6 @@
|
||||
#include "i2c_master.h"
|
||||
#include "progmem.h"
|
||||
|
||||
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
@ -47,23 +44,23 @@
|
||||
#define ISSI_INTERRUPTMASKREGISTER 0xF0
|
||||
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
|
||||
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
|
||||
#define ISSI_PAGE_PWM 0x01 //PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 //PG3
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
|
||||
#define ISSI_PAGE_PWM 0x01 // PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 // PG3
|
||||
|
||||
#define ISSI_REG_CONFIGURATION 0x00 //PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
|
||||
#define ISSI_REG_RESET 0x11// PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F //PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 //PG3
|
||||
#define ISSI_REG_CONFIGURATION 0x00 // PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
|
||||
#define ISSI_REG_RESET 0x11 // PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F // PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 // PG3
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
#define ISSI_PERSISTENCE 0
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
@ -76,124 +73,113 @@ uint8_t g_twi_transfer_buffer[20];
|
||||
// buffers and the transfers in IS31FL3736_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 }, { 0 } };
|
||||
bool g_led_control_registers_update_required = false;
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}};
|
||||
bool g_led_control_registers_update_required = false;
|
||||
|
||||
void IS31FL3736_write_register( uint8_t addr, uint8_t reg, uint8_t data )
|
||||
{
|
||||
void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3736_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
{
|
||||
void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for ( int i = 0; i < 192; i += 16 ) {
|
||||
for (int i = 0; i < 192; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
for ( int j = 0; j < 16; j++ ) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3736_init( uint8_t addr )
|
||||
{
|
||||
void IS31FL3736_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG0
|
||||
IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
// Turn off all LEDs.
|
||||
for ( int i = 0x00; i <= 0x17; i++ )
|
||||
{
|
||||
IS31FL3736_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0x17; i++) {
|
||||
IS31FL3736_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG1
|
||||
IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for ( int i = 0x00; i <= 0xBF; i++ )
|
||||
{
|
||||
IS31FL3736_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0xBF; i++) {
|
||||
IS31FL3736_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG3
|
||||
IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
|
||||
IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
|
||||
// Set global current to maximum.
|
||||
IS31FL3736_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
|
||||
IS31FL3736_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
|
||||
// Disable software shutdown.
|
||||
IS31FL3736_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 );
|
||||
IS31FL3736_write_register(addr, ISSI_REG_CONFIGURATION, 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms( 10 );
|
||||
#else
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms(10);
|
||||
#else
|
||||
wait_ms(10);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3736_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
|
||||
void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required = true;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3736_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
|
||||
{
|
||||
IS31FL3736_set_color( i, red, green, blue );
|
||||
void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL3736_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
|
||||
{
|
||||
void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
// IS31FL3733
|
||||
@ -209,64 +195,59 @@ void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, b
|
||||
// A1-A4=0x00 A5-A8=0x01
|
||||
// So, the same math applies.
|
||||
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if ( red ) {
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if ( green ) {
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if ( blue ) {
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = true;
|
||||
|
||||
}
|
||||
|
||||
void IS31FL3736_mono_set_brightness( int index, uint8_t value )
|
||||
{
|
||||
if ( index >= 0 && index < 96 ) {
|
||||
// Index in range 0..95 -> A1..A8, B1..B8, etc.
|
||||
// Map index 0..95 to registers 0x00..0xBE (interleaved)
|
||||
uint8_t pwm_register = index * 2;
|
||||
void IS31FL3736_mono_set_brightness(int index, uint8_t value) {
|
||||
if (index >= 0 && index < 96) {
|
||||
// Index in range 0..95 -> A1..A8, B1..B8, etc.
|
||||
// Map index 0..95 to registers 0x00..0xBE (interleaved)
|
||||
uint8_t pwm_register = index * 2;
|
||||
g_pwm_buffer[0][pwm_register] = value;
|
||||
g_pwm_buffer_update_required = true;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3736_mono_set_brightness_all( uint8_t value )
|
||||
{
|
||||
for ( int i = 0; i < 96; i++ )
|
||||
{
|
||||
IS31FL3736_mono_set_brightness( i, value );
|
||||
void IS31FL3736_mono_set_brightness_all(uint8_t value) {
|
||||
for (int i = 0; i < 96; i++) {
|
||||
IS31FL3736_mono_set_brightness(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled )
|
||||
{
|
||||
// Index in range 0..95 -> A1..A8, B1..B8, etc.
|
||||
void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled) {
|
||||
// Index in range 0..95 -> A1..A8, B1..B8, etc.
|
||||
|
||||
// Map index 0..95 to registers 0x00..0xBE (interleaved)
|
||||
uint8_t pwm_register = index * 2;
|
||||
// Map register 0x00..0xBE (interleaved) into control register and bit
|
||||
uint8_t control_register = pwm_register / 8;
|
||||
uint8_t bit = pwm_register % 8;
|
||||
// Map index 0..95 to registers 0x00..0xBE (interleaved)
|
||||
uint8_t pwm_register = index * 2;
|
||||
// Map register 0x00..0xBE (interleaved) into control register and bit
|
||||
uint8_t control_register = pwm_register / 8;
|
||||
uint8_t bit = pwm_register % 8;
|
||||
|
||||
if ( enabled ) {
|
||||
if (enabled) {
|
||||
g_led_control_registers[0][control_register] |= (1 << bit);
|
||||
} else {
|
||||
g_led_control_registers[0][control_register] &= ~(1 << bit);
|
||||
@ -275,32 +256,26 @@ void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled )
|
||||
g_led_control_registers_update_required = true;
|
||||
}
|
||||
|
||||
void IS31FL3736_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
|
||||
{
|
||||
if ( g_pwm_buffer_update_required )
|
||||
{
|
||||
void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2) {
|
||||
if (g_pwm_buffer_update_required) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
|
||||
IS31FL3736_write_pwm_buffer( addr1, g_pwm_buffer[0] );
|
||||
//IS31FL3736_write_pwm_buffer( addr2, g_pwm_buffer[1] );
|
||||
IS31FL3736_write_pwm_buffer(addr1, g_pwm_buffer[0]);
|
||||
// IS31FL3736_write_pwm_buffer( addr2, g_pwm_buffer[1] );
|
||||
}
|
||||
g_pwm_buffer_update_required = false;
|
||||
}
|
||||
|
||||
void IS31FL3736_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
|
||||
{
|
||||
if ( g_led_control_registers_update_required )
|
||||
{
|
||||
void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2) {
|
||||
if (g_led_control_registers_update_required) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
for ( int i=0; i<24; i++ )
|
||||
{
|
||||
IS31FL3736_write_register(addr1, i, g_led_control_registers[0][i] );
|
||||
//IS31FL3736_write_register(addr2, i, g_led_control_registers[1][i] );
|
||||
IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
for (int i = 0; i < 24; i++) {
|
||||
IS31FL3736_write_register(addr1, i, g_led_control_registers[0][i]);
|
||||
// IS31FL3736_write_register(addr2, i, g_led_control_registers[1][i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,154 +19,150 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
// Simple interface option.
|
||||
// If these aren't defined, just define them to make it compile
|
||||
|
||||
|
||||
#ifndef DRIVER_COUNT
|
||||
#define DRIVER_COUNT 2
|
||||
# define DRIVER_COUNT 2
|
||||
#endif
|
||||
|
||||
#ifndef DRIVER_LED_TOTAL
|
||||
#define DRIVER_LED_TOTAL 96
|
||||
# define DRIVER_LED_TOTAL 96
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver:2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t driver : 2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL3736_init( uint8_t addr );
|
||||
void IS31FL3736_write_register( uint8_t addr, uint8_t reg, uint8_t data );
|
||||
void IS31FL3736_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
|
||||
void IS31FL3736_init(uint8_t addr);
|
||||
void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
|
||||
void IS31FL3736_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3736_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
|
||||
void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
|
||||
|
||||
void IS31FL3736_mono_set_brightness( int index, uint8_t value );
|
||||
void IS31FL3736_mono_set_brightness_all( uint8_t value );
|
||||
void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled );
|
||||
void IS31FL3736_mono_set_brightness(int index, uint8_t value);
|
||||
void IS31FL3736_mono_set_brightness_all(uint8_t value);
|
||||
void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void IS31FL3736_update_pwm_buffers( uint8_t addr1, uint8_t addr2 );
|
||||
void IS31FL3736_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
|
||||
void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
|
||||
void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2);
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x02
|
||||
#define A_3 0x04
|
||||
#define A_4 0x06
|
||||
#define A_5 0x08
|
||||
#define A_6 0x0A
|
||||
#define A_7 0x0C
|
||||
#define A_8 0x0E
|
||||
#define A_1 0x00
|
||||
#define A_2 0x02
|
||||
#define A_3 0x04
|
||||
#define A_4 0x06
|
||||
#define A_5 0x08
|
||||
#define A_6 0x0A
|
||||
#define A_7 0x0C
|
||||
#define A_8 0x0E
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x12
|
||||
#define B_3 0x14
|
||||
#define B_4 0x16
|
||||
#define B_5 0x18
|
||||
#define B_6 0x1A
|
||||
#define B_7 0x1C
|
||||
#define B_8 0x1E
|
||||
#define B_1 0x10
|
||||
#define B_2 0x12
|
||||
#define B_3 0x14
|
||||
#define B_4 0x16
|
||||
#define B_5 0x18
|
||||
#define B_6 0x1A
|
||||
#define B_7 0x1C
|
||||
#define B_8 0x1E
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x22
|
||||
#define C_3 0x24
|
||||
#define C_4 0x26
|
||||
#define C_5 0x28
|
||||
#define C_6 0x2A
|
||||
#define C_7 0x2C
|
||||
#define C_8 0x2E
|
||||
#define C_1 0x20
|
||||
#define C_2 0x22
|
||||
#define C_3 0x24
|
||||
#define C_4 0x26
|
||||
#define C_5 0x28
|
||||
#define C_6 0x2A
|
||||
#define C_7 0x2C
|
||||
#define C_8 0x2E
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x32
|
||||
#define D_3 0x34
|
||||
#define D_4 0x36
|
||||
#define D_5 0x38
|
||||
#define D_6 0x3A
|
||||
#define D_7 0x3C
|
||||
#define D_8 0x3E
|
||||
#define D_1 0x30
|
||||
#define D_2 0x32
|
||||
#define D_3 0x34
|
||||
#define D_4 0x36
|
||||
#define D_5 0x38
|
||||
#define D_6 0x3A
|
||||
#define D_7 0x3C
|
||||
#define D_8 0x3E
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x42
|
||||
#define E_3 0x44
|
||||
#define E_4 0x46
|
||||
#define E_5 0x48
|
||||
#define E_6 0x4A
|
||||
#define E_7 0x4C
|
||||
#define E_8 0x4E
|
||||
#define E_1 0x40
|
||||
#define E_2 0x42
|
||||
#define E_3 0x44
|
||||
#define E_4 0x46
|
||||
#define E_5 0x48
|
||||
#define E_6 0x4A
|
||||
#define E_7 0x4C
|
||||
#define E_8 0x4E
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x52
|
||||
#define F_3 0x54
|
||||
#define F_4 0x56
|
||||
#define F_5 0x58
|
||||
#define F_6 0x5A
|
||||
#define F_7 0x5C
|
||||
#define F_8 0x5E
|
||||
#define F_1 0x50
|
||||
#define F_2 0x52
|
||||
#define F_3 0x54
|
||||
#define F_4 0x56
|
||||
#define F_5 0x58
|
||||
#define F_6 0x5A
|
||||
#define F_7 0x5C
|
||||
#define F_8 0x5E
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x62
|
||||
#define G_3 0x64
|
||||
#define G_4 0x66
|
||||
#define G_5 0x68
|
||||
#define G_6 0x6A
|
||||
#define G_7 0x6C
|
||||
#define G_8 0x6E
|
||||
#define G_1 0x60
|
||||
#define G_2 0x62
|
||||
#define G_3 0x64
|
||||
#define G_4 0x66
|
||||
#define G_5 0x68
|
||||
#define G_6 0x6A
|
||||
#define G_7 0x6C
|
||||
#define G_8 0x6E
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x72
|
||||
#define H_3 0x74
|
||||
#define H_4 0x76
|
||||
#define H_5 0x78
|
||||
#define H_6 0x7A
|
||||
#define H_7 0x7C
|
||||
#define H_8 0x7E
|
||||
#define H_1 0x70
|
||||
#define H_2 0x72
|
||||
#define H_3 0x74
|
||||
#define H_4 0x76
|
||||
#define H_5 0x78
|
||||
#define H_6 0x7A
|
||||
#define H_7 0x7C
|
||||
#define H_8 0x7E
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x82
|
||||
#define I_3 0x84
|
||||
#define I_4 0x86
|
||||
#define I_5 0x88
|
||||
#define I_6 0x8A
|
||||
#define I_7 0x8C
|
||||
#define I_8 0x8E
|
||||
#define I_1 0x80
|
||||
#define I_2 0x82
|
||||
#define I_3 0x84
|
||||
#define I_4 0x86
|
||||
#define I_5 0x88
|
||||
#define I_6 0x8A
|
||||
#define I_7 0x8C
|
||||
#define I_8 0x8E
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x92
|
||||
#define J_3 0x94
|
||||
#define J_4 0x96
|
||||
#define J_5 0x98
|
||||
#define J_6 0x9A
|
||||
#define J_7 0x9C
|
||||
#define J_8 0x9E
|
||||
#define J_1 0x90
|
||||
#define J_2 0x92
|
||||
#define J_3 0x94
|
||||
#define J_4 0x96
|
||||
#define J_5 0x98
|
||||
#define J_6 0x9A
|
||||
#define J_7 0x9C
|
||||
#define J_8 0x9E
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA2
|
||||
#define K_3 0xA4
|
||||
#define K_4 0xA6
|
||||
#define K_5 0xA8
|
||||
#define K_6 0xAA
|
||||
#define K_7 0xAC
|
||||
#define K_8 0xAE
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB2
|
||||
#define L_3 0xB4
|
||||
#define L_4 0xB6
|
||||
#define L_5 0xB8
|
||||
#define L_6 0xBA
|
||||
#define L_7 0xBC
|
||||
#define L_8 0xBE
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA2
|
||||
#define K_3 0xA4
|
||||
#define K_4 0xA6
|
||||
#define K_5 0xA8
|
||||
#define K_6 0xAA
|
||||
#define K_7 0xAC
|
||||
#define K_8 0xAE
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB2
|
||||
#define L_3 0xB4
|
||||
#define L_4 0xB6
|
||||
#define L_5 0xB8
|
||||
#define L_6 0xBA
|
||||
#define L_7 0xBC
|
||||
#define L_8 0xBE
|
||||
|
@ -17,11 +17,11 @@
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
# include <avr/interrupt.h>
|
||||
# include <avr/io.h>
|
||||
# include <util/delay.h>
|
||||
#else
|
||||
#include "wait.h"
|
||||
# include "wait.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@ -46,23 +46,23 @@
|
||||
#define ISSI_INTERRUPTMASKREGISTER 0xF0
|
||||
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
|
||||
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
|
||||
#define ISSI_PAGE_PWM 0x01 //PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 //PG3
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
|
||||
#define ISSI_PAGE_PWM 0x01 // PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 // PG3
|
||||
|
||||
#define ISSI_REG_CONFIGURATION 0x00 //PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
|
||||
#define ISSI_REG_RESET 0x11// PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F //PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 //PG3
|
||||
#define ISSI_REG_CONFIGURATION 0x00 // PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
|
||||
#define ISSI_REG_RESET 0x11 // PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F // PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 // PG3
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
#define ISSI_PERSISTENCE 0
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
@ -75,178 +75,161 @@ uint8_t g_twi_transfer_buffer[20];
|
||||
// buffers and the transfers in IS31FL3737_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 } };
|
||||
bool g_led_control_registers_update_required = false;
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}};
|
||||
bool g_led_control_registers_update_required = false;
|
||||
|
||||
void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data )
|
||||
{
|
||||
void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
{
|
||||
void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for ( int i = 0; i < 192; i += 16 ) {
|
||||
for (int i = 0; i < 192; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
for ( int j = 0; j < 16; j++ ) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3737_init( uint8_t addr )
|
||||
{
|
||||
void IS31FL3737_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG0
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
// Turn off all LEDs.
|
||||
for ( int i = 0x00; i <= 0x17; i++ )
|
||||
{
|
||||
IS31FL3737_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0x17; i++) {
|
||||
IS31FL3737_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG1
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for ( int i = 0x00; i <= 0xBF; i++ )
|
||||
{
|
||||
IS31FL3737_write_register( addr, i, 0x00 );
|
||||
for (int i = 0x00; i <= 0xBF; i++) {
|
||||
IS31FL3737_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG3
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
|
||||
IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
|
||||
// Set global current to maximum.
|
||||
IS31FL3737_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
|
||||
IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
|
||||
// Disable software shutdown.
|
||||
IS31FL3737_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 );
|
||||
IS31FL3737_write_register(addr, ISSI_REG_CONFIGURATION, 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms( 10 );
|
||||
#else
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms(10);
|
||||
#else
|
||||
wait_ms(10);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
|
||||
void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required = true;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
|
||||
{
|
||||
IS31FL3737_set_color( i, red, green, blue );
|
||||
void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL3737_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
|
||||
{
|
||||
void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if ( red ) {
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if ( green ) {
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if ( blue ) {
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = true;
|
||||
|
||||
}
|
||||
|
||||
void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
|
||||
{
|
||||
if ( g_pwm_buffer_update_required )
|
||||
{
|
||||
void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2) {
|
||||
if (g_pwm_buffer_update_required) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
|
||||
IS31FL3737_write_pwm_buffer( addr1, g_pwm_buffer[0] );
|
||||
//IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] );
|
||||
IS31FL3737_write_pwm_buffer(addr1, g_pwm_buffer[0]);
|
||||
// IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] );
|
||||
}
|
||||
g_pwm_buffer_update_required = false;
|
||||
}
|
||||
|
||||
void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
|
||||
{
|
||||
if ( g_led_control_registers_update_required )
|
||||
{
|
||||
void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2) {
|
||||
if (g_led_control_registers_update_required) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
for ( int i=0; i<24; i++ )
|
||||
{
|
||||
IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i] );
|
||||
//IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] );
|
||||
IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
for (int i = 0; i < 24; i++) {
|
||||
IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i]);
|
||||
// IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IS31FL3737_DRIVER_H
|
||||
#define IS31FL3737_DRIVER_H
|
||||
|
||||
@ -24,184 +23,184 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver:2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t driver : 2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL3737_init( uint8_t addr );
|
||||
void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data );
|
||||
void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
|
||||
void IS31FL3737_init(uint8_t addr);
|
||||
void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
|
||||
void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
|
||||
void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 );
|
||||
void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
|
||||
void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
|
||||
void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2);
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x08
|
||||
#define A_8 0x09
|
||||
#define A_9 0x0A
|
||||
#define A_10 0x0B
|
||||
#define A_11 0x0C
|
||||
#define A_12 0x0D
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x08
|
||||
#define A_8 0x09
|
||||
#define A_9 0x0A
|
||||
#define A_10 0x0B
|
||||
#define A_11 0x0C
|
||||
#define A_12 0x0D
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x18
|
||||
#define B_8 0x19
|
||||
#define B_9 0x1A
|
||||
#define B_10 0x1B
|
||||
#define B_11 0x1C
|
||||
#define B_12 0x1D
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x18
|
||||
#define B_8 0x19
|
||||
#define B_9 0x1A
|
||||
#define B_10 0x1B
|
||||
#define B_11 0x1C
|
||||
#define B_12 0x1D
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x28
|
||||
#define C_8 0x29
|
||||
#define C_9 0x2A
|
||||
#define C_10 0x2B
|
||||
#define C_11 0x2C
|
||||
#define C_12 0x2D
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x28
|
||||
#define C_8 0x29
|
||||
#define C_9 0x2A
|
||||
#define C_10 0x2B
|
||||
#define C_11 0x2C
|
||||
#define C_12 0x2D
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x38
|
||||
#define D_8 0x39
|
||||
#define D_9 0x3A
|
||||
#define D_10 0x3B
|
||||
#define D_11 0x3C
|
||||
#define D_12 0x3D
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x38
|
||||
#define D_8 0x39
|
||||
#define D_9 0x3A
|
||||
#define D_10 0x3B
|
||||
#define D_11 0x3C
|
||||
#define D_12 0x3D
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x48
|
||||
#define E_8 0x49
|
||||
#define E_9 0x4A
|
||||
#define E_10 0x4B
|
||||
#define E_11 0x4C
|
||||
#define E_12 0x4D
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x48
|
||||
#define E_8 0x49
|
||||
#define E_9 0x4A
|
||||
#define E_10 0x4B
|
||||
#define E_11 0x4C
|
||||
#define E_12 0x4D
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x58
|
||||
#define F_8 0x59
|
||||
#define F_9 0x5A
|
||||
#define F_10 0x5B
|
||||
#define F_11 0x5C
|
||||
#define F_12 0x5D
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x58
|
||||
#define F_8 0x59
|
||||
#define F_9 0x5A
|
||||
#define F_10 0x5B
|
||||
#define F_11 0x5C
|
||||
#define F_12 0x5D
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x68
|
||||
#define G_8 0x69
|
||||
#define G_9 0x6A
|
||||
#define G_10 0x6B
|
||||
#define G_11 0x6C
|
||||
#define G_12 0x6D
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x68
|
||||
#define G_8 0x69
|
||||
#define G_9 0x6A
|
||||
#define G_10 0x6B
|
||||
#define G_11 0x6C
|
||||
#define G_12 0x6D
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x78
|
||||
#define H_8 0x79
|
||||
#define H_9 0x7A
|
||||
#define H_10 0x7B
|
||||
#define H_11 0x7C
|
||||
#define H_12 0x7D
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x78
|
||||
#define H_8 0x79
|
||||
#define H_9 0x7A
|
||||
#define H_10 0x7B
|
||||
#define H_11 0x7C
|
||||
#define H_12 0x7D
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x88
|
||||
#define I_8 0x89
|
||||
#define I_9 0x8A
|
||||
#define I_10 0x8B
|
||||
#define I_11 0x8C
|
||||
#define I_12 0x8D
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x88
|
||||
#define I_8 0x89
|
||||
#define I_9 0x8A
|
||||
#define I_10 0x8B
|
||||
#define I_11 0x8C
|
||||
#define I_12 0x8D
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x98
|
||||
#define J_8 0x99
|
||||
#define J_9 0x9A
|
||||
#define J_10 0x9B
|
||||
#define J_11 0x9C
|
||||
#define J_12 0x9D
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x98
|
||||
#define J_8 0x99
|
||||
#define J_9 0x9A
|
||||
#define J_10 0x9B
|
||||
#define J_11 0x9C
|
||||
#define J_12 0x9D
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA8
|
||||
#define K_8 0xA9
|
||||
#define K_9 0xAA
|
||||
#define K_10 0xAB
|
||||
#define K_11 0xAC
|
||||
#define K_12 0xAD
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA8
|
||||
#define K_8 0xA9
|
||||
#define K_9 0xAA
|
||||
#define K_10 0xAB
|
||||
#define K_11 0xAC
|
||||
#define K_12 0xAD
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB8
|
||||
#define L_8 0xB9
|
||||
#define L_9 0xBA
|
||||
#define L_10 0xBB
|
||||
#define L_11 0xBC
|
||||
#define L_12 0xBD
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB8
|
||||
#define L_8 0xB9
|
||||
#define L_9 0xBA
|
||||
#define L_10 0xBB
|
||||
#define L_11 0xBC
|
||||
#define L_12 0xBD
|
||||
|
||||
#endif // IS31FL3737_DRIVER_H
|
||||
#endif // IS31FL3737_DRIVER_H
|
||||
|
@ -1,240 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
# include <avr/io.h>
|
||||
# include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <pgmspace.h>
|
||||
# include <pgmspace.h>
|
||||
#else
|
||||
#define PROGMEM
|
||||
# define PROGMEM
|
||||
#endif
|
||||
|
||||
// Helidox 8x6 font with QMK Firmware Logo
|
||||
// Online editor: http://teripom.x0.com/
|
||||
|
||||
static const unsigned char font[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26, 0x00,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07, 0x00,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14, 0x00,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A, 0x00,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60, 0x00,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08, 0x00,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10, 0x00,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10, 0x00,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30, 0x00,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62, 0x00,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50, 0x00,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08, 0x00,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46, 0x00,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33, 0x00,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10, 0x00,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39, 0x00,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07, 0x00,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36, 0x00,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E, 0x00,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x00,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08, 0x00,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06, 0x00,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36, 0x00,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22, 0x00,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41, 0x00,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01, 0x00,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73, 0x00,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41, 0x00,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40, 0x00,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06, 0x00,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46, 0x00,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32, 0x00,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03, 0x00,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63, 0x00,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03, 0x00,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43, 0x00,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41, 0x00,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F, 0x00,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04, 0x00,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40, 0x00,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38, 0x00,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F, 0x00,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18, 0x00,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02, 0x00,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78, 0x00,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78, 0x00,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78, 0x00,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38, 0x00,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18, 0x00,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC, 0x00,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08, 0x00,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24, 0x00,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24, 0x00,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44, 0x00,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44, 0x00,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8,
|
||||
0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F,
|
||||
0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8,
|
||||
0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00,
|
||||
0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00,
|
||||
0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0,
|
||||
0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0,
|
||||
0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0,
|
||||
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,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E,
|
||||
0x1E, 0x06, 0x01, 0x00, 0x00, 0x00,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00,
|
||||
0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B,
|
||||
0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00,
|
||||
0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE,
|
||||
0xDE, 0xD7, 0xDC, 0x00, 0xC0, 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,
|
||||
0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00,
|
||||
0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F,
|
||||
0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00,
|
||||
0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E,
|
||||
0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F,
|
||||
0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F,
|
||||
0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E,
|
||||
0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00,
|
||||
0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E,
|
||||
0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F,
|
||||
0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70,
|
||||
0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49,
|
||||
0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E,
|
||||
0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69,
|
||||
0x69, 0x6F, 0x26, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C,
|
||||
0x78, 0x70, 0x60, 0x00, 0x00, 0x00,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00,
|
||||
0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20,
|
||||
0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00,
|
||||
0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F,
|
||||
0x0F, 0x7F, 0x0F, 0x00, 0x03, 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, 0x01, 0x01, 0x07, 0x0F, 0x0F,
|
||||
0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E,
|
||||
0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F,
|
||||
0x0F, 0x07, 0x01, 0x01, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x01, 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, 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, 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, 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, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E,
|
||||
0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 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, 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F,
|
||||
0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 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, 0x01, 0x01, 0x07, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
@ -23,67 +23,66 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
# include <avr/io.h>
|
||||
# include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <pgmspace.h>
|
||||
#else // defined(ESP8266)
|
||||
#define PROGMEM
|
||||
#define memcpy_P(des, src, len) memcpy(des, src, len)
|
||||
#endif // defined(__AVR__)
|
||||
# include <pgmspace.h>
|
||||
#else // defined(ESP8266)
|
||||
# define PROGMEM
|
||||
# define memcpy_P(des, src, len) memcpy(des, src, len)
|
||||
#endif // defined(__AVR__)
|
||||
|
||||
// Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
|
||||
// for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf
|
||||
|
||||
// Fundamental Commands
|
||||
#define CONTRAST 0x81
|
||||
#define DISPLAY_ALL_ON 0xA5
|
||||
#define DISPLAY_ALL_ON_RESUME 0xA4
|
||||
#define NORMAL_DISPLAY 0xA6
|
||||
#define DISPLAY_ON 0xAF
|
||||
#define DISPLAY_OFF 0xAE
|
||||
#define NOP 0xE3
|
||||
#define CONTRAST 0x81
|
||||
#define DISPLAY_ALL_ON 0xA5
|
||||
#define DISPLAY_ALL_ON_RESUME 0xA4
|
||||
#define NORMAL_DISPLAY 0xA6
|
||||
#define DISPLAY_ON 0xAF
|
||||
#define DISPLAY_OFF 0xAE
|
||||
#define NOP 0xE3
|
||||
|
||||
// Scrolling Commands
|
||||
#define ACTIVATE_SCROLL 0x2F
|
||||
#define DEACTIVATE_SCROLL 0x2E
|
||||
#define SCROLL_RIGHT 0x26
|
||||
#define SCROLL_LEFT 0x27
|
||||
#define SCROLL_RIGHT_UP 0x29
|
||||
#define SCROLL_LEFT_UP 0x2A
|
||||
#define ACTIVATE_SCROLL 0x2F
|
||||
#define DEACTIVATE_SCROLL 0x2E
|
||||
#define SCROLL_RIGHT 0x26
|
||||
#define SCROLL_LEFT 0x27
|
||||
#define SCROLL_RIGHT_UP 0x29
|
||||
#define SCROLL_LEFT_UP 0x2A
|
||||
|
||||
// Addressing Setting Commands
|
||||
#define MEMORY_MODE 0x20
|
||||
#define COLUMN_ADDR 0x21
|
||||
#define PAGE_ADDR 0x22
|
||||
#define PAM_SETCOLUMN_LSB 0x00
|
||||
#define PAM_SETCOLUMN_MSB 0x10
|
||||
#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
|
||||
#define MEMORY_MODE 0x20
|
||||
#define COLUMN_ADDR 0x21
|
||||
#define PAGE_ADDR 0x22
|
||||
#define PAM_SETCOLUMN_LSB 0x00
|
||||
#define PAM_SETCOLUMN_MSB 0x10
|
||||
#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
|
||||
|
||||
// Hardware Configuration Commands
|
||||
#define DISPLAY_START_LINE 0x40
|
||||
#define SEGMENT_REMAP 0xA0
|
||||
#define SEGMENT_REMAP_INV 0xA1
|
||||
#define MULTIPLEX_RATIO 0xA8
|
||||
#define COM_SCAN_INC 0xC0
|
||||
#define COM_SCAN_DEC 0xC8
|
||||
#define DISPLAY_OFFSET 0xD3
|
||||
#define COM_PINS 0xDA
|
||||
#define COM_PINS_SEQ 0x02
|
||||
#define COM_PINS_ALT 0x12
|
||||
#define COM_PINS_SEQ_LR 0x22
|
||||
#define COM_PINS_ALT_LR 0x32
|
||||
#define DISPLAY_START_LINE 0x40
|
||||
#define SEGMENT_REMAP 0xA0
|
||||
#define SEGMENT_REMAP_INV 0xA1
|
||||
#define MULTIPLEX_RATIO 0xA8
|
||||
#define COM_SCAN_INC 0xC0
|
||||
#define COM_SCAN_DEC 0xC8
|
||||
#define DISPLAY_OFFSET 0xD3
|
||||
#define COM_PINS 0xDA
|
||||
#define COM_PINS_SEQ 0x02
|
||||
#define COM_PINS_ALT 0x12
|
||||
#define COM_PINS_SEQ_LR 0x22
|
||||
#define COM_PINS_ALT_LR 0x32
|
||||
|
||||
// Timing & Driving Commands
|
||||
#define DISPLAY_CLOCK 0xD5
|
||||
#define PRE_CHARGE_PERIOD 0xD9
|
||||
#define VCOM_DETECT 0xDB
|
||||
#define DISPLAY_CLOCK 0xD5
|
||||
#define PRE_CHARGE_PERIOD 0xD9
|
||||
#define VCOM_DETECT 0xDB
|
||||
|
||||
// Charge Pump Commands
|
||||
#define CHARGE_PUMP 0x8D
|
||||
#define CHARGE_PUMP 0x8D
|
||||
|
||||
// Misc defines
|
||||
#define OLED_TIMEOUT 60000
|
||||
#define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8)
|
||||
#define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)
|
||||
|
||||
@ -91,12 +90,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define I2C_CMD 0x00
|
||||
#define I2C_DATA 0x40
|
||||
#if defined(__AVR__)
|
||||
// already defined on ARM
|
||||
#define I2C_TIMEOUT 100
|
||||
#define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
|
||||
#else // defined(__AVR__)
|
||||
#define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
|
||||
#endif // defined(__AVR__)
|
||||
// already defined on ARM
|
||||
# define I2C_TIMEOUT 100
|
||||
# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
|
||||
#else // defined(__AVR__)
|
||||
# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
|
||||
#endif // defined(__AVR__)
|
||||
#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
|
||||
#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, I2C_TIMEOUT)
|
||||
|
||||
@ -106,16 +105,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// this is so we don't end up with rounding errors with
|
||||
// parts of the display unusable or don't get cleared correctly
|
||||
// and also allows for drawing & inverting
|
||||
uint8_t oled_buffer[OLED_MATRIX_SIZE];
|
||||
uint8_t* oled_cursor;
|
||||
OLED_BLOCK_TYPE oled_dirty = 0;
|
||||
bool oled_initialized = false;
|
||||
bool oled_active = false;
|
||||
bool oled_scrolling = false;
|
||||
uint8_t oled_rotation = 0;
|
||||
uint8_t oled_rotation_width = 0;
|
||||
#if !defined(OLED_DISABLE_TIMEOUT)
|
||||
uint16_t oled_last_activity;
|
||||
uint8_t oled_buffer[OLED_MATRIX_SIZE];
|
||||
uint8_t * oled_cursor;
|
||||
OLED_BLOCK_TYPE oled_dirty = 0;
|
||||
bool oled_initialized = false;
|
||||
bool oled_active = false;
|
||||
bool oled_scrolling = false;
|
||||
uint8_t oled_rotation = 0;
|
||||
uint8_t oled_rotation_width = 0;
|
||||
#if OLED_TIMEOUT > 0
|
||||
uint32_t oled_timeout;
|
||||
#endif
|
||||
#if OLED_SCROLL_TIMEOUT > 0
|
||||
uint32_t oled_scroll_timeout;
|
||||
#endif
|
||||
|
||||
// Internal variables to reduce math instructions
|
||||
@ -123,443 +125,445 @@ uint8_t oled_rotation_width = 0;
|
||||
#if defined(__AVR__)
|
||||
// identical to i2c_transmit, but for PROGMEM since all initialization is in PROGMEM arrays currently
|
||||
// probably should move this into i2c_master...
|
||||
static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
|
||||
i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
|
||||
static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout) {
|
||||
i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
|
||||
|
||||
for (uint16_t i = 0; i < length && status >= 0; i++) {
|
||||
status = i2c_write(pgm_read_byte((const char*)data++), timeout);
|
||||
if (status) break;
|
||||
}
|
||||
for (uint16_t i = 0; i < length && status >= 0; i++) {
|
||||
status = i2c_write(pgm_read_byte((const char *)data++), timeout);
|
||||
if (status) break;
|
||||
}
|
||||
|
||||
i2c_stop();
|
||||
i2c_stop();
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Flips the rendering bits for a character at the current cursor position
|
||||
static void InvertCharacter(uint8_t *cursor)
|
||||
{
|
||||
const uint8_t *end = cursor + OLED_FONT_WIDTH;
|
||||
while (cursor < end) {
|
||||
*cursor = ~(*cursor);
|
||||
cursor++;
|
||||
}
|
||||
static void InvertCharacter(uint8_t *cursor) {
|
||||
const uint8_t *end = cursor + OLED_FONT_WIDTH;
|
||||
while (cursor < end) {
|
||||
*cursor = ~(*cursor);
|
||||
cursor++;
|
||||
}
|
||||
}
|
||||
|
||||
bool oled_init(uint8_t rotation) {
|
||||
oled_rotation = oled_init_user(rotation);
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
oled_rotation_width = OLED_DISPLAY_WIDTH;
|
||||
} else {
|
||||
oled_rotation_width = OLED_DISPLAY_HEIGHT;
|
||||
}
|
||||
i2c_init();
|
||||
oled_rotation = oled_init_user(rotation);
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
oled_rotation_width = OLED_DISPLAY_WIDTH;
|
||||
} else {
|
||||
oled_rotation_width = OLED_DISPLAY_HEIGHT;
|
||||
}
|
||||
i2c_init();
|
||||
|
||||
static const uint8_t PROGMEM display_setup1[] = {
|
||||
I2C_CMD,
|
||||
DISPLAY_OFF,
|
||||
DISPLAY_CLOCK, 0x80,
|
||||
MULTIPLEX_RATIO, OLED_DISPLAY_HEIGHT - 1,
|
||||
DISPLAY_OFFSET, 0x00,
|
||||
DISPLAY_START_LINE | 0x00,
|
||||
CHARGE_PUMP, 0x14,
|
||||
static const uint8_t PROGMEM display_setup1[] = {
|
||||
I2C_CMD,
|
||||
DISPLAY_OFF,
|
||||
DISPLAY_CLOCK,
|
||||
0x80,
|
||||
MULTIPLEX_RATIO,
|
||||
OLED_DISPLAY_HEIGHT - 1,
|
||||
DISPLAY_OFFSET,
|
||||
0x00,
|
||||
DISPLAY_START_LINE | 0x00,
|
||||
CHARGE_PUMP,
|
||||
0x14,
|
||||
#if (OLED_IC != OLED_IC_SH1106)
|
||||
// MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
|
||||
MEMORY_MODE, 0x00, // Horizontal addressing mode
|
||||
// MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
|
||||
MEMORY_MODE,
|
||||
0x00, // Horizontal addressing mode
|
||||
#endif
|
||||
};
|
||||
if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_init cmd set 1 failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) {
|
||||
static const uint8_t PROGMEM display_normal[] = {
|
||||
I2C_CMD,
|
||||
SEGMENT_REMAP_INV,
|
||||
COM_SCAN_DEC };
|
||||
if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_init cmd normal rotation failed\n");
|
||||
return false;
|
||||
};
|
||||
if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_init cmd set 1 failed\n");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
static const uint8_t PROGMEM display_flipped[] = {
|
||||
I2C_CMD,
|
||||
SEGMENT_REMAP,
|
||||
COM_SCAN_INC };
|
||||
if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) {
|
||||
print("display_flipped failed\n");
|
||||
return false;
|
||||
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) {
|
||||
static const uint8_t PROGMEM display_normal[] = {I2C_CMD, SEGMENT_REMAP_INV, COM_SCAN_DEC};
|
||||
if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_init cmd normal rotation failed\n");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
static const uint8_t PROGMEM display_flipped[] = {I2C_CMD, SEGMENT_REMAP, COM_SCAN_INC};
|
||||
if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) {
|
||||
print("display_flipped failed\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const uint8_t PROGMEM display_setup2[] = {
|
||||
I2C_CMD,
|
||||
COM_PINS, OLED_COM_PINS,
|
||||
CONTRAST, 0x8F,
|
||||
PRE_CHARGE_PERIOD, 0xF1,
|
||||
VCOM_DETECT, 0x40,
|
||||
DISPLAY_ALL_ON_RESUME,
|
||||
NORMAL_DISPLAY,
|
||||
DEACTIVATE_SCROLL,
|
||||
DISPLAY_ON };
|
||||
if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) {
|
||||
print("display_setup2 failed\n");
|
||||
return false;
|
||||
}
|
||||
static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, 0x8F, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x40, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON};
|
||||
if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) {
|
||||
print("display_setup2 failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
oled_clear();
|
||||
oled_initialized = true;
|
||||
oled_active = true;
|
||||
oled_scrolling = false;
|
||||
return true;
|
||||
#if OLED_TIMEOUT > 0
|
||||
oled_timeout = timer_read32() + OLED_TIMEOUT;
|
||||
#endif
|
||||
#if OLED_SCROLL_TIMEOUT > 0
|
||||
oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
|
||||
#endif
|
||||
|
||||
oled_clear();
|
||||
oled_initialized = true;
|
||||
oled_active = true;
|
||||
oled_scrolling = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
return rotation;
|
||||
}
|
||||
__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; }
|
||||
|
||||
void oled_clear(void) {
|
||||
memset(oled_buffer, 0, sizeof(oled_buffer));
|
||||
oled_cursor = &oled_buffer[0];
|
||||
oled_dirty = -1; // -1 will be max value as long as display_dirty is unsigned type
|
||||
memset(oled_buffer, 0, sizeof(oled_buffer));
|
||||
oled_cursor = &oled_buffer[0];
|
||||
oled_dirty = -1; // -1 will be max value as long as display_dirty is unsigned type
|
||||
}
|
||||
|
||||
static void calc_bounds(uint8_t update_start, uint8_t* cmd_array)
|
||||
{
|
||||
// Calculate commands to set memory addressing bounds.
|
||||
uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH;
|
||||
uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH;
|
||||
static void calc_bounds(uint8_t update_start, uint8_t *cmd_array) {
|
||||
// Calculate commands to set memory addressing bounds.
|
||||
uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH;
|
||||
uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH;
|
||||
#if (OLED_IC == OLED_IC_SH1106)
|
||||
// Commands for Page Addressing Mode. Sets starting page and column; has no end bound.
|
||||
// Column value must be split into high and low nybble and sent as two commands.
|
||||
cmd_array[0] = PAM_PAGE_ADDR | start_page;
|
||||
cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f);
|
||||
cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f);
|
||||
cmd_array[3] = NOP;
|
||||
cmd_array[4] = NOP;
|
||||
cmd_array[5] = NOP;
|
||||
// Commands for Page Addressing Mode. Sets starting page and column; has no end bound.
|
||||
// Column value must be split into high and low nybble and sent as two commands.
|
||||
cmd_array[0] = PAM_PAGE_ADDR | start_page;
|
||||
cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f);
|
||||
cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f);
|
||||
cmd_array[3] = NOP;
|
||||
cmd_array[4] = NOP;
|
||||
cmd_array[5] = NOP;
|
||||
#else
|
||||
// Commands for use in Horizontal Addressing mode.
|
||||
cmd_array[1] = start_column;
|
||||
cmd_array[4] = start_page;
|
||||
cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1];
|
||||
cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1;
|
||||
// Commands for use in Horizontal Addressing mode.
|
||||
cmd_array[1] = start_column;
|
||||
cmd_array[4] = start_page;
|
||||
cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1];
|
||||
cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calc_bounds_90(uint8_t update_start, uint8_t* cmd_array)
|
||||
{
|
||||
cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8;
|
||||
cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT;
|
||||
cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1];;
|
||||
cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8;
|
||||
static void calc_bounds_90(uint8_t update_start, uint8_t *cmd_array) {
|
||||
cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8;
|
||||
cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT;
|
||||
cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1];
|
||||
;
|
||||
cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8;
|
||||
}
|
||||
|
||||
uint8_t crot(uint8_t a, int8_t n)
|
||||
{
|
||||
const uint8_t mask = 0x7;
|
||||
n &= mask;
|
||||
return a << n | a >> (-n & mask);
|
||||
uint8_t crot(uint8_t a, int8_t n) {
|
||||
const uint8_t mask = 0x7;
|
||||
n &= mask;
|
||||
return a << n | a >> (-n & mask);
|
||||
}
|
||||
|
||||
static void rotate_90(const uint8_t* src, uint8_t* dest)
|
||||
{
|
||||
for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) {
|
||||
uint8_t selector = (1 << i);
|
||||
for (uint8_t j = 0; j < 8; ++j) {
|
||||
dest[i] |= crot(src[j] & selector, shift - (int8_t)j);
|
||||
static void rotate_90(const uint8_t *src, uint8_t *dest) {
|
||||
for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) {
|
||||
uint8_t selector = (1 << i);
|
||||
for (uint8_t j = 0; j < 8; ++j) {
|
||||
dest[i] |= crot(src[j] & selector, shift - (int8_t)j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void oled_render(void) {
|
||||
// Do we have work to do?
|
||||
if (!oled_dirty || oled_scrolling) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find first dirty block
|
||||
uint8_t update_start = 0;
|
||||
while (!(oled_dirty & (1 << update_start))) { ++update_start; }
|
||||
|
||||
// Set column & page position
|
||||
static uint8_t display_start[] = {
|
||||
I2C_CMD,
|
||||
COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1,
|
||||
PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1 };
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
|
||||
} else {
|
||||
calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
|
||||
}
|
||||
|
||||
// Send column & page position
|
||||
if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_render offset command failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
// Send render data chunk as is
|
||||
if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_render data failed\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Rotate the render chunks
|
||||
const static uint8_t source_map[] = OLED_SOURCE_MAP;
|
||||
const static uint8_t target_map[] = OLED_TARGET_MAP;
|
||||
|
||||
static uint8_t temp_buffer[OLED_BLOCK_SIZE];
|
||||
memset(temp_buffer, 0, sizeof(temp_buffer));
|
||||
for(uint8_t i = 0; i < sizeof(source_map); ++i) {
|
||||
rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]);
|
||||
// Do we have work to do?
|
||||
if (!oled_dirty || oled_scrolling) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send render data chunk after rotating
|
||||
if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_render90 data failed\n");
|
||||
return;
|
||||
// Find first dirty block
|
||||
uint8_t update_start = 0;
|
||||
while (!(oled_dirty & (1 << update_start))) {
|
||||
++update_start;
|
||||
}
|
||||
}
|
||||
|
||||
// Turn on display if it is off
|
||||
oled_on();
|
||||
// Set column & page position
|
||||
static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1};
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
|
||||
} else {
|
||||
calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
|
||||
}
|
||||
|
||||
// Clear dirty flag
|
||||
oled_dirty &= ~(1 << update_start);
|
||||
// Send column & page position
|
||||
if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_render offset command failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
// Send render data chunk as is
|
||||
if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_render data failed\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Rotate the render chunks
|
||||
const static uint8_t source_map[] = OLED_SOURCE_MAP;
|
||||
const static uint8_t target_map[] = OLED_TARGET_MAP;
|
||||
|
||||
static uint8_t temp_buffer[OLED_BLOCK_SIZE];
|
||||
memset(temp_buffer, 0, sizeof(temp_buffer));
|
||||
for (uint8_t i = 0; i < sizeof(source_map); ++i) {
|
||||
rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]);
|
||||
}
|
||||
|
||||
// Send render data chunk after rotating
|
||||
if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_render90 data failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Turn on display if it is off
|
||||
oled_on();
|
||||
|
||||
// Clear dirty flag
|
||||
oled_dirty &= ~(1 << update_start);
|
||||
}
|
||||
|
||||
void oled_set_cursor(uint8_t col, uint8_t line) {
|
||||
uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH;
|
||||
uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH;
|
||||
|
||||
// Out of bounds?
|
||||
if (index >= OLED_MATRIX_SIZE) {
|
||||
index = 0;
|
||||
}
|
||||
// Out of bounds?
|
||||
if (index >= OLED_MATRIX_SIZE) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
oled_cursor = &oled_buffer[index];
|
||||
oled_cursor = &oled_buffer[index];
|
||||
}
|
||||
|
||||
void oled_advance_page(bool clearPageRemainder) {
|
||||
uint16_t index = oled_cursor - &oled_buffer[0];
|
||||
uint8_t remaining = oled_rotation_width - (index % oled_rotation_width);
|
||||
uint16_t index = oled_cursor - &oled_buffer[0];
|
||||
uint8_t remaining = oled_rotation_width - (index % oled_rotation_width);
|
||||
|
||||
if (clearPageRemainder) {
|
||||
// Remaining Char count
|
||||
remaining = remaining / OLED_FONT_WIDTH;
|
||||
if (clearPageRemainder) {
|
||||
// Remaining Char count
|
||||
remaining = remaining / OLED_FONT_WIDTH;
|
||||
|
||||
// Write empty character until next line
|
||||
while (remaining--)
|
||||
oled_write_char(' ', false);
|
||||
} else {
|
||||
// Next page index out of bounds?
|
||||
if (index + remaining >= OLED_MATRIX_SIZE) {
|
||||
index = 0;
|
||||
remaining = 0;
|
||||
// Write empty character until next line
|
||||
while (remaining--) oled_write_char(' ', false);
|
||||
} else {
|
||||
// Next page index out of bounds?
|
||||
if (index + remaining >= OLED_MATRIX_SIZE) {
|
||||
index = 0;
|
||||
remaining = 0;
|
||||
}
|
||||
|
||||
oled_cursor = &oled_buffer[index + remaining];
|
||||
}
|
||||
|
||||
oled_cursor = &oled_buffer[index + remaining];
|
||||
}
|
||||
}
|
||||
|
||||
void oled_advance_char(void) {
|
||||
uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH;
|
||||
uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width);
|
||||
uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH;
|
||||
uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width);
|
||||
|
||||
// Do we have enough space on the current line for the next character
|
||||
if (remainingSpace < OLED_FONT_WIDTH) {
|
||||
nextIndex += remainingSpace;
|
||||
}
|
||||
// Do we have enough space on the current line for the next character
|
||||
if (remainingSpace < OLED_FONT_WIDTH) {
|
||||
nextIndex += remainingSpace;
|
||||
}
|
||||
|
||||
// Did we go out of bounds
|
||||
if (nextIndex >= OLED_MATRIX_SIZE) {
|
||||
nextIndex = 0;
|
||||
}
|
||||
// Did we go out of bounds
|
||||
if (nextIndex >= OLED_MATRIX_SIZE) {
|
||||
nextIndex = 0;
|
||||
}
|
||||
|
||||
// Update cursor position
|
||||
oled_cursor = &oled_buffer[nextIndex];
|
||||
// Update cursor position
|
||||
oled_cursor = &oled_buffer[nextIndex];
|
||||
}
|
||||
|
||||
// Main handler that writes character data to the display buffer
|
||||
void oled_write_char(const char data, bool invert) {
|
||||
// Advance to the next line if newline
|
||||
if (data == '\n') {
|
||||
// Old source wrote ' ' until end of line...
|
||||
oled_advance_page(true);
|
||||
return;
|
||||
}
|
||||
// Advance to the next line if newline
|
||||
if (data == '\n') {
|
||||
// Old source wrote ' ' until end of line...
|
||||
oled_advance_page(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data == '\r') {
|
||||
oled_advance_page(false);
|
||||
return;
|
||||
}
|
||||
if (data == '\r') {
|
||||
oled_advance_page(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// copy the current render buffer to check for dirty after
|
||||
static uint8_t oled_temp_buffer[OLED_FONT_WIDTH];
|
||||
memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH);
|
||||
// copy the current render buffer to check for dirty after
|
||||
static uint8_t oled_temp_buffer[OLED_FONT_WIDTH];
|
||||
memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH);
|
||||
|
||||
// set the reder buffer data
|
||||
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
|
||||
if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) {
|
||||
memset(oled_cursor, 0x00, OLED_FONT_WIDTH);
|
||||
} else {
|
||||
const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH];
|
||||
memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH);
|
||||
}
|
||||
// set the reder buffer data
|
||||
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
|
||||
if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) {
|
||||
memset(oled_cursor, 0x00, OLED_FONT_WIDTH);
|
||||
} else {
|
||||
const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH];
|
||||
memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH);
|
||||
}
|
||||
|
||||
// Invert if needed
|
||||
if (invert) {
|
||||
InvertCharacter(oled_cursor);
|
||||
}
|
||||
// Invert if needed
|
||||
if (invert) {
|
||||
InvertCharacter(oled_cursor);
|
||||
}
|
||||
|
||||
// Dirty check
|
||||
if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) {
|
||||
uint16_t index = oled_cursor - &oled_buffer[0];
|
||||
oled_dirty |= (1 << (index / OLED_BLOCK_SIZE));
|
||||
// Edgecase check if the written data spans the 2 chunks
|
||||
oled_dirty |= (1 << ((index + OLED_FONT_WIDTH) / OLED_BLOCK_SIZE));
|
||||
}
|
||||
// Dirty check
|
||||
if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) {
|
||||
uint16_t index = oled_cursor - &oled_buffer[0];
|
||||
oled_dirty |= (1 << (index / OLED_BLOCK_SIZE));
|
||||
// Edgecase check if the written data spans the 2 chunks
|
||||
oled_dirty |= (1 << ((index + OLED_FONT_WIDTH) / OLED_BLOCK_SIZE));
|
||||
}
|
||||
|
||||
// Finally move to the next char
|
||||
oled_advance_char();
|
||||
// Finally move to the next char
|
||||
oled_advance_char();
|
||||
}
|
||||
|
||||
void oled_write(const char *data, bool invert) {
|
||||
const char *end = data + strlen(data);
|
||||
while (data < end) {
|
||||
oled_write_char(*data, invert);
|
||||
data++;
|
||||
}
|
||||
const char *end = data + strlen(data);
|
||||
while (data < end) {
|
||||
oled_write_char(*data, invert);
|
||||
data++;
|
||||
}
|
||||
}
|
||||
|
||||
void oled_write_ln(const char *data, bool invert) {
|
||||
oled_write(data, invert);
|
||||
oled_advance_page(true);
|
||||
oled_write(data, invert);
|
||||
oled_advance_page(true);
|
||||
}
|
||||
|
||||
#if defined(__AVR__)
|
||||
void oled_write_P(const char *data, bool invert) {
|
||||
uint8_t c = pgm_read_byte(data);
|
||||
while (c != 0) {
|
||||
oled_write_char(c, invert);
|
||||
c = pgm_read_byte(++data);
|
||||
}
|
||||
uint8_t c = pgm_read_byte(data);
|
||||
while (c != 0) {
|
||||
oled_write_char(c, invert);
|
||||
c = pgm_read_byte(++data);
|
||||
}
|
||||
}
|
||||
|
||||
void oled_write_ln_P(const char *data, bool invert) {
|
||||
oled_write_P(data, invert);
|
||||
oled_advance_page(true);
|
||||
oled_write_P(data, invert);
|
||||
oled_advance_page(true);
|
||||
}
|
||||
#endif // defined(__AVR__)
|
||||
#endif // defined(__AVR__)
|
||||
|
||||
bool oled_on(void) {
|
||||
#if !defined(OLED_DISABLE_TIMEOUT)
|
||||
oled_last_activity = timer_read();
|
||||
#if OLED_TIMEOUT > 0
|
||||
oled_timeout = timer_read32() + OLED_TIMEOUT;
|
||||
#endif
|
||||
|
||||
static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON };
|
||||
if (!oled_active) {
|
||||
if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_on cmd failed\n");
|
||||
return oled_active;
|
||||
static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON};
|
||||
if (!oled_active) {
|
||||
if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_on cmd failed\n");
|
||||
return oled_active;
|
||||
}
|
||||
oled_active = true;
|
||||
}
|
||||
oled_active = true;
|
||||
}
|
||||
return oled_active;
|
||||
return oled_active;
|
||||
}
|
||||
|
||||
bool oled_off(void) {
|
||||
static const uint8_t PROGMEM display_off[] = { I2C_CMD, DISPLAY_OFF };
|
||||
if (oled_active) {
|
||||
if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_off cmd failed\n");
|
||||
return oled_active;
|
||||
static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF};
|
||||
if (oled_active) {
|
||||
if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_off cmd failed\n");
|
||||
return oled_active;
|
||||
}
|
||||
oled_active = false;
|
||||
}
|
||||
oled_active = false;
|
||||
}
|
||||
return !oled_active;
|
||||
return !oled_active;
|
||||
}
|
||||
|
||||
bool oled_scroll_right(void) {
|
||||
// Dont enable scrolling if we need to update the display
|
||||
// This prevents scrolling of bad data from starting the scroll too early after init
|
||||
if (!oled_dirty && !oled_scrolling) {
|
||||
static const uint8_t PROGMEM display_scroll_right[] = {
|
||||
I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL };
|
||||
if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_scroll_right cmd failed\n");
|
||||
return oled_scrolling;
|
||||
// Dont enable scrolling if we need to update the display
|
||||
// This prevents scrolling of bad data from starting the scroll too early after init
|
||||
if (!oled_dirty && !oled_scrolling) {
|
||||
static const uint8_t PROGMEM display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL};
|
||||
if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_scroll_right cmd failed\n");
|
||||
return oled_scrolling;
|
||||
}
|
||||
oled_scrolling = true;
|
||||
}
|
||||
oled_scrolling = true;
|
||||
}
|
||||
return oled_scrolling;
|
||||
return oled_scrolling;
|
||||
}
|
||||
|
||||
bool oled_scroll_left(void) {
|
||||
// Dont enable scrolling if we need to update the display
|
||||
// This prevents scrolling of bad data from starting the scroll too early after init
|
||||
if (!oled_dirty && !oled_scrolling) {
|
||||
static const uint8_t PROGMEM display_scroll_left[] = {
|
||||
I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL };
|
||||
if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_scroll_left cmd failed\n");
|
||||
return oled_scrolling;
|
||||
// Dont enable scrolling if we need to update the display
|
||||
// This prevents scrolling of bad data from starting the scroll too early after init
|
||||
if (!oled_dirty && !oled_scrolling) {
|
||||
static const uint8_t PROGMEM display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL};
|
||||
if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_scroll_left cmd failed\n");
|
||||
return oled_scrolling;
|
||||
}
|
||||
oled_scrolling = true;
|
||||
}
|
||||
oled_scrolling = true;
|
||||
}
|
||||
return oled_scrolling;
|
||||
return oled_scrolling;
|
||||
}
|
||||
|
||||
bool oled_scroll_off(void) {
|
||||
if (oled_scrolling) {
|
||||
static const uint8_t PROGMEM display_scroll_off[] = { I2C_CMD, DEACTIVATE_SCROLL };
|
||||
if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_scroll_off cmd failed\n");
|
||||
return oled_scrolling;
|
||||
if (oled_scrolling) {
|
||||
static const uint8_t PROGMEM display_scroll_off[] = {I2C_CMD, DEACTIVATE_SCROLL};
|
||||
if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) {
|
||||
print("oled_scroll_off cmd failed\n");
|
||||
return oled_scrolling;
|
||||
}
|
||||
oled_scrolling = false;
|
||||
oled_dirty = -1;
|
||||
}
|
||||
oled_scrolling = false;
|
||||
}
|
||||
return !oled_scrolling;
|
||||
return !oled_scrolling;
|
||||
}
|
||||
|
||||
uint8_t oled_max_chars(void) {
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH;
|
||||
}
|
||||
return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH;
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH;
|
||||
}
|
||||
return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH;
|
||||
}
|
||||
|
||||
uint8_t oled_max_lines(void) {
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT;
|
||||
}
|
||||
return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT;
|
||||
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
|
||||
return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT;
|
||||
}
|
||||
return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT;
|
||||
}
|
||||
|
||||
void oled_task(void) {
|
||||
if (!oled_initialized) {
|
||||
return;
|
||||
}
|
||||
if (!oled_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
oled_set_cursor(0, 0);
|
||||
oled_set_cursor(0, 0);
|
||||
|
||||
oled_task_user();
|
||||
oled_task_user();
|
||||
|
||||
// Smart render system, no need to check for dirty
|
||||
oled_render();
|
||||
#if OLED_SCROLL_TIMEOUT > 0
|
||||
if (oled_dirty && oled_scrolling) {
|
||||
oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
|
||||
oled_scroll_off();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Display timeout check
|
||||
#if !defined(OLED_DISABLE_TIMEOUT)
|
||||
if (oled_active && timer_elapsed(oled_last_activity) > OLED_TIMEOUT) {
|
||||
oled_off();
|
||||
}
|
||||
// Smart render system, no need to check for dirty
|
||||
oled_render();
|
||||
|
||||
// Display timeout check
|
||||
#if OLED_TIMEOUT > 0
|
||||
if (oled_active && timer_expired32(timer_read32(), oled_timeout)) {
|
||||
oled_off();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OLED_SCROLL_TIMEOUT > 0
|
||||
if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) {
|
||||
# ifdef OLED_SCROLL_TIMEOUT_RIGHT
|
||||
oled_scroll_right();
|
||||
# else
|
||||
oled_scroll_left();
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void oled_task_user(void) {
|
||||
}
|
||||
__attribute__((weak)) void oled_task_user(void) {}
|
||||
|
@ -21,121 +21,133 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// an enumeration of the chips this driver supports
|
||||
#define OLED_IC_SSD1306 0
|
||||
#define OLED_IC_SH1106 1
|
||||
#define OLED_IC_SH1106 1
|
||||
|
||||
#if defined(OLED_DISPLAY_CUSTOM)
|
||||
// Expected user to implement the necessary defines
|
||||
// Expected user to implement the necessary defines
|
||||
#elif defined(OLED_DISPLAY_128X64)
|
||||
// Double height 128x64
|
||||
#ifndef OLED_DISPLAY_WIDTH
|
||||
#define OLED_DISPLAY_WIDTH 128
|
||||
#endif
|
||||
#ifndef OLED_DISPLAY_HEIGHT
|
||||
#define OLED_DISPLAY_HEIGHT 64
|
||||
#endif
|
||||
#ifndef OLED_MATRIX_SIZE
|
||||
#define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed)
|
||||
#endif
|
||||
#ifndef OLED_BLOCK_TYPE
|
||||
#define OLED_BLOCK_TYPE uint16_t
|
||||
#endif
|
||||
#ifndef OLED_BLOCK_COUNT
|
||||
#define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed)
|
||||
#endif
|
||||
#ifndef OLED_BLOCK_SIZE
|
||||
#define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
|
||||
#endif
|
||||
#ifndef OLED_COM_PINS
|
||||
#define OLED_COM_PINS COM_PINS_ALT
|
||||
#endif
|
||||
// Double height 128x64
|
||||
# ifndef OLED_DISPLAY_WIDTH
|
||||
# define OLED_DISPLAY_WIDTH 128
|
||||
# endif
|
||||
# ifndef OLED_DISPLAY_HEIGHT
|
||||
# define OLED_DISPLAY_HEIGHT 64
|
||||
# endif
|
||||
# ifndef OLED_MATRIX_SIZE
|
||||
# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed)
|
||||
# endif
|
||||
# ifndef OLED_BLOCK_TYPE
|
||||
# define OLED_BLOCK_TYPE uint16_t
|
||||
# endif
|
||||
# ifndef OLED_BLOCK_COUNT
|
||||
# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed)
|
||||
# endif
|
||||
# ifndef OLED_BLOCK_SIZE
|
||||
# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
|
||||
# endif
|
||||
# ifndef OLED_COM_PINS
|
||||
# define OLED_COM_PINS COM_PINS_ALT
|
||||
# endif
|
||||
|
||||
// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
|
||||
// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
|
||||
#ifndef OLED_SOURCE_MAP
|
||||
#define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
|
||||
#endif
|
||||
#ifndef OLED_TARGET_MAP
|
||||
#define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
|
||||
#endif
|
||||
// If OLED_BLOCK_TYPE is uint32_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 32, 40, 48, 56 }
|
||||
// #define OLED_TARGET_MAP { 24, 16, 8, 0 }
|
||||
// If OLED_BLOCK_TYPE is uint16_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
|
||||
// #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
|
||||
// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }
|
||||
// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 }
|
||||
#else // defined(OLED_DISPLAY_128X64)
|
||||
// Default 128x32
|
||||
#ifndef OLED_DISPLAY_WIDTH
|
||||
#define OLED_DISPLAY_WIDTH 128
|
||||
#endif
|
||||
#ifndef OLED_DISPLAY_HEIGHT
|
||||
#define OLED_DISPLAY_HEIGHT 32
|
||||
#endif
|
||||
#ifndef OLED_MATRIX_SIZE
|
||||
#define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed)
|
||||
#endif
|
||||
#ifndef OLED_BLOCK_TYPE
|
||||
#define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only
|
||||
#endif
|
||||
#ifndef OLED_BLOCK_COUNT
|
||||
#define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed)
|
||||
#endif
|
||||
#ifndef OLED_BLOCK_SIZE
|
||||
#define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
|
||||
#endif
|
||||
#ifndef OLED_COM_PINS
|
||||
#define OLED_COM_PINS COM_PINS_SEQ
|
||||
#endif
|
||||
// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
|
||||
// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
|
||||
# ifndef OLED_SOURCE_MAP
|
||||
# define OLED_SOURCE_MAP \
|
||||
{ 0, 8, 16, 24, 32, 40, 48, 56 }
|
||||
# endif
|
||||
# ifndef OLED_TARGET_MAP
|
||||
# define OLED_TARGET_MAP \
|
||||
{ 56, 48, 40, 32, 24, 16, 8, 0 }
|
||||
# endif
|
||||
// If OLED_BLOCK_TYPE is uint32_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 32, 40, 48, 56 }
|
||||
// #define OLED_TARGET_MAP { 24, 16, 8, 0 }
|
||||
// If OLED_BLOCK_TYPE is uint16_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
|
||||
// #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
|
||||
// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }
|
||||
// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 }
|
||||
#else // defined(OLED_DISPLAY_128X64)
|
||||
// Default 128x32
|
||||
# ifndef OLED_DISPLAY_WIDTH
|
||||
# define OLED_DISPLAY_WIDTH 128
|
||||
# endif
|
||||
# ifndef OLED_DISPLAY_HEIGHT
|
||||
# define OLED_DISPLAY_HEIGHT 32
|
||||
# endif
|
||||
# ifndef OLED_MATRIX_SIZE
|
||||
# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed)
|
||||
# endif
|
||||
# ifndef OLED_BLOCK_TYPE
|
||||
# define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only
|
||||
# endif
|
||||
# ifndef OLED_BLOCK_COUNT
|
||||
# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed)
|
||||
# endif
|
||||
# ifndef OLED_BLOCK_SIZE
|
||||
# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
|
||||
# endif
|
||||
# ifndef OLED_COM_PINS
|
||||
# define OLED_COM_PINS COM_PINS_SEQ
|
||||
# endif
|
||||
|
||||
// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
|
||||
// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
|
||||
#ifndef OLED_SOURCE_MAP
|
||||
#define OLED_SOURCE_MAP { 0, 8, 16, 24 }
|
||||
#endif
|
||||
#ifndef OLED_TARGET_MAP
|
||||
#define OLED_TARGET_MAP { 24, 16, 8, 0 }
|
||||
#endif
|
||||
// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
|
||||
// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 }
|
||||
#endif // defined(OLED_DISPLAY_CUSTOM)
|
||||
// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
|
||||
// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
|
||||
# ifndef OLED_SOURCE_MAP
|
||||
# define OLED_SOURCE_MAP \
|
||||
{ 0, 8, 16, 24 }
|
||||
# endif
|
||||
# ifndef OLED_TARGET_MAP
|
||||
# define OLED_TARGET_MAP \
|
||||
{ 24, 16, 8, 0 }
|
||||
# endif
|
||||
// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
|
||||
// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
|
||||
// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 }
|
||||
#endif // defined(OLED_DISPLAY_CUSTOM)
|
||||
|
||||
#if !defined(OLED_IC)
|
||||
#define OLED_IC OLED_IC_SSD1306
|
||||
# define OLED_IC OLED_IC_SSD1306
|
||||
#endif
|
||||
|
||||
// the column address corresponding to the first column in the display hardware
|
||||
#if !defined(OLED_COLUMN_OFFSET)
|
||||
#define OLED_COLUMN_OFFSET 0
|
||||
# define OLED_COLUMN_OFFSET 0
|
||||
#endif
|
||||
|
||||
// Address to use for the i2c oled communication
|
||||
#if !defined(OLED_DISPLAY_ADDRESS)
|
||||
#define OLED_DISPLAY_ADDRESS 0x3C
|
||||
# define OLED_DISPLAY_ADDRESS 0x3C
|
||||
#endif
|
||||
|
||||
// Custom font file to use
|
||||
#if !defined(OLED_FONT_H)
|
||||
#define OLED_FONT_H "glcdfont.c"
|
||||
# define OLED_FONT_H "glcdfont.c"
|
||||
#endif
|
||||
// unsigned char value of the first character in the font file
|
||||
#if !defined(OLED_FONT_START)
|
||||
#define OLED_FONT_START 0
|
||||
# define OLED_FONT_START 0
|
||||
#endif
|
||||
// unsigned char value of the last character in the font file
|
||||
#if !defined(OLED_FONT_END)
|
||||
#define OLED_FONT_END 224
|
||||
# define OLED_FONT_END 224
|
||||
#endif
|
||||
// Font render width
|
||||
#if !defined(OLED_FONT_WIDTH)
|
||||
#define OLED_FONT_WIDTH 6
|
||||
# define OLED_FONT_WIDTH 6
|
||||
#endif
|
||||
// Font render height
|
||||
#if !defined(OLED_FONT_HEIGHT)
|
||||
#define OLED_FONT_HEIGHT 8
|
||||
# define OLED_FONT_HEIGHT 8
|
||||
#endif
|
||||
|
||||
#if !defined(OLED_TIMEOUT)
|
||||
# if defined(OLED_DISABLE_TIMEOUT)
|
||||
# define OLED_TIMEOUT 0
|
||||
# else
|
||||
# define OLED_TIMEOUT 60000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// OLED Rotation enum values are flags
|
||||
@ -143,7 +155,7 @@ typedef enum {
|
||||
OLED_ROTATION_0 = 0,
|
||||
OLED_ROTATION_90 = 1,
|
||||
OLED_ROTATION_180 = 2,
|
||||
OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180
|
||||
OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180
|
||||
} oled_rotation_t;
|
||||
|
||||
// Initialize the oled display, rotating the rendered output based on the define passed in.
|
||||
@ -200,15 +212,15 @@ void oled_write_P(const char *data, bool invert);
|
||||
// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM
|
||||
void oled_write_ln_P(const char *data, bool invert);
|
||||
#else
|
||||
// Writes a string to the buffer at current cursor position
|
||||
// Advances the cursor while writing, inverts the pixels if true
|
||||
#define oled_write_P(data, invert) oled_write(data, invert)
|
||||
// Writes a string to the buffer at current cursor position
|
||||
// Advances the cursor while writing, inverts the pixels if true
|
||||
# define oled_write_P(data, invert) oled_write(data, invert)
|
||||
|
||||
// Writes a string to the buffer at current cursor position
|
||||
// Advances the cursor while writing, inverts the pixels if true
|
||||
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
|
||||
#define oled_write_ln_P(data, invert) oled_write(data, invert)
|
||||
#endif // defined(__AVR__)
|
||||
// Writes a string to the buffer at current cursor position
|
||||
// Advances the cursor while writing, inverts the pixels if true
|
||||
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
|
||||
# define oled_write_ln_P(data, invert) oled_write(data, invert)
|
||||
#endif // defined(__AVR__)
|
||||
|
||||
// Can be used to manually turn on the screen if it is off
|
||||
// Returns true if the screen was on or turns on
|
||||
|
@ -35,16 +35,21 @@
|
||||
#include "string.h"
|
||||
|
||||
#define TOTALFONTS 2
|
||||
const unsigned char * fonts_pointer[]= { font5x7, font8x16 };
|
||||
const unsigned char* fonts_pointer[] = {font5x7, font8x16};
|
||||
|
||||
uint8_t foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY;
|
||||
uint8_t foreColor, drawMode, fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY;
|
||||
uint16_t fontMapWidth;
|
||||
|
||||
#define _BV(x) (1 << (x))
|
||||
#define swap(a, b) { uint8_t t = a; a = b; b = t; }
|
||||
#define swap(a, b) \
|
||||
{ \
|
||||
uint8_t t = a; \
|
||||
a = b; \
|
||||
b = t; \
|
||||
}
|
||||
|
||||
uint8_t micro_oled_transfer_buffer[20];
|
||||
static uint8_t micro_oled_screen_current[LCDWIDTH*LCDWIDTH/8] = { 0 };
|
||||
uint8_t micro_oled_transfer_buffer[20];
|
||||
static uint8_t micro_oled_screen_current[LCDWIDTH * LCDWIDTH / 8] = {0};
|
||||
|
||||
/* LCD Memory organised in 64 horizontal pixel and 6 rows of byte
|
||||
B B .............B -----
|
||||
@ -64,628 +69,399 @@ static uint8_t micro_oled_screen_current[LCDWIDTH*LCDWIDTH/8] = { 0 };
|
||||
*/
|
||||
|
||||
#if LCDWIDTH == 64
|
||||
#if LCDWIDTH == 48
|
||||
# if LCDWIDTH == 48
|
||||
static uint8_t micro_oled_screen_buffer[] = {
|
||||
// QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php
|
||||
//64x48 image
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00,
|
||||
0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00,
|
||||
0x00, 0xF0, 0xF0, 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, 0x60, 0x60, 0x60, 0x60,
|
||||
0xF8, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFE,
|
||||
0xFE, 0xF8, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x8C, 0x8C, 0x8C, 0x8C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8C, 0x8C, 0x8C, 0x8C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x31, 0x31, 0x31, 0x31, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF1, 0xE3, 0xE7, 0xCF,
|
||||
0xCF, 0xCF, 0xCF, 0x00, 0x00, 0xCF, 0xCF, 0xCF, 0xC7, 0xE7,
|
||||
0xE3, 0xF1, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x31, 0x31, 0x31, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06,
|
||||
0x06, 0x06, 0x1F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0x7F, 0x7F, 0x1F, 0x06, 0x06, 0x06, 0x06, 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, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
#endif
|
||||
// QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php
|
||||
// 64x48 image
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 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, 0x60, 0x60, 0x60, 0x60, 0xF8, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xF8, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x8C, 0x8C, 0x8C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8C, 0x8C, 0x8C, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x31, 0x31, 0x31, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF1, 0xE3, 0xE7, 0xCF, 0xCF, 0xCF, 0xCF, 0x00, 0x00, 0xCF, 0xCF, 0xCF, 0xC7, 0xE7, 0xE3, 0xF1, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x31, 0x31, 0x31, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x1F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x1F, 0x06, 0x06, 0x06, 0x06, 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, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
# endif
|
||||
#elif LCDWIDTH == 128
|
||||
#if LCDHEIGHT == 32
|
||||
static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {
|
||||
//128x32 qmk image
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xFC, 0xFC,
|
||||
0xE0, 0xF0, 0xFC, 0xE0, 0xE0, 0xFC, 0xE0, 0xE0, 0xFC, 0xFC,
|
||||
0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x30, 0xE0, 0x00, 0x00,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00,
|
||||
0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
|
||||
0x80, 0xF0, 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, 0x12, 0xB2, 0xB2, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0x03,
|
||||
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xB7, 0xB2, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x1F, 0x02, 0x02, 0x03, 0x01, 0x00, 0x06, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x1F, 0x06, 0x00, 0x03, 0x1E, 0x18, 0x0F, 0x01,
|
||||
0x0F, 0x18, 0x1E, 0x01, 0x00, 0x0F, 0x1F, 0x12, 0x02, 0x12,
|
||||
0x13, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x12,
|
||||
0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x1F,
|
||||
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, 0x48, 0x4D, 0x4D, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFE, 0xF8, 0xF9, 0xF3, 0xF3, 0xC0, 0x80, 0xF3,
|
||||
0xF3, 0xF3, 0xF9, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED,
|
||||
0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0xC0, 0x00, 0x70, 0xC0,
|
||||
0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0C,
|
||||
0x04, 0x04, 0x04, 0x04, 0x1C, 0xF0, 0x00, 0x00, 0xFC, 0x0C,
|
||||
0x38, 0xE0, 0x00, 0x00, 0xC0, 0x38, 0x0C, 0xFC, 0x00, 0x00,
|
||||
0xFC, 0xFC, 0x60, 0x90, 0x0C, 0x04, 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, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x3F,
|
||||
0x3F, 0x07, 0x3F, 0x3F, 0x07, 0x0F, 0x3F, 0x07, 0x07, 0x3F,
|
||||
0x07, 0x07, 0x3F, 0x3F, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
|
||||
0x06, 0x04, 0x04, 0x07, 0x01, 0x00, 0x00, 0x13, 0x1E, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x04, 0x04,
|
||||
0x04, 0x04, 0x07, 0x0D, 0x08, 0x00, 0x07, 0x00, 0x00, 0x01,
|
||||
0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x07,
|
||||
0x00, 0x01, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00
|
||||
};
|
||||
#elif LCDHEIGHT == 64
|
||||
static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {
|
||||
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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0,
|
||||
0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00,
|
||||
0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xC0, 0xC0, 0xC0, 0xC0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF,
|
||||
0x7F, 0x7E, 0xFE, 0xFF, 0xFF, 0xFE, 0xFE, 0x7F, 0x7F, 0xFE,
|
||||
0xFE, 0xFF, 0xFF, 0xFE, 0x7E, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC,
|
||||
0xFC, 0xF8, 0xC0, 0xC0, 0xC0, 0xC0, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x88, 0x88, 0x88, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xDD, 0x88, 0x88, 0x88, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x99, 0x99, 0x99, 0x99, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xF3, 0xF3, 0xE7, 0xE7, 0x00,
|
||||
0x00, 0xE7, 0xE7, 0xF3, 0xF3, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 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, 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,
|
||||
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, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x1F, 0x3F,
|
||||
0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F,
|
||||
0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF,
|
||||
0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x01, 0x01, 0x01, 0x01, 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, 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, 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, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00,
|
||||
0x80, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x00, 0x80, 0x01,
|
||||
0x03, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x70,
|
||||
0x88, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x00, 0x3C, 0xE0, 0xC0,
|
||||
0x38, 0x1C, 0xE0, 0x80, 0x70, 0x0C, 0x00, 0xF8, 0xAC, 0x24,
|
||||
0x24, 0x3C, 0x30, 0x00, 0x00, 0xFC, 0x0C, 0x04, 0x00, 0xF8,
|
||||
0xAC, 0x24, 0x24, 0x2C, 0x30, 0x00, 0x70, 0xDC, 0x04, 0x04,
|
||||
0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
|
||||
0x8C, 0x04, 0x04, 0xF8, 0x00, 0x04, 0x3C, 0xE0, 0x80, 0xF0,
|
||||
0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x83, 0x01, 0x01,
|
||||
0x01, 0x81, 0xFE, 0x3C, 0x00, 0x00, 0xFF, 0x03, 0x0E, 0x70,
|
||||
0xC0, 0xE0, 0x38, 0x06, 0x03, 0xFF, 0x00, 0x00, 0xFF, 0x18,
|
||||
0x38, 0x66, 0xC3, 0x01, 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,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 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, 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, 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, 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, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
//TODO: generate bitmap of QMK logo here
|
||||
#endif
|
||||
# if LCDHEIGHT == 32
|
||||
static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {
|
||||
// 128x32 qmk image
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xFC, 0xFC, 0xE0, 0xF0, 0xFC, 0xE0, 0xE0, 0xFC, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x30, 0xE0, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xF0, 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, 0x12, 0xB2, 0xB2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0x03, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xB7, 0xB2, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x02, 0x02, 0x03, 0x01, 0x00, 0x06, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x06, 0x00, 0x03, 0x1E, 0x18, 0x0F, 0x01, 0x0F, 0x18, 0x1E, 0x01, 0x00, 0x0F, 0x1F, 0x12, 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x12, 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x1F, 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, 0x48, 0x4D, 0x4D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF9, 0xF3, 0xF3, 0xC0, 0x80, 0xF3, 0xF3, 0xF3, 0xF9, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0xC0, 0x00, 0x70, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x1C, 0xF0, 0x00, 0x00, 0xFC, 0x0C, 0x38, 0xE0, 0x00, 0x00, 0xC0, 0x38, 0x0C, 0xFC, 0x00, 0x00, 0xFC, 0xFC, 0x60, 0x90, 0x0C, 0x04, 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, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x3F, 0x3F, 0x07, 0x0F, 0x3F, 0x07, 0x07, 0x3F, 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x06, 0x04, 0x04, 0x07, 0x01, 0x00, 0x00, 0x13, 0x1E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x04, 0x04, 0x04, 0x04, 0x07, 0x0D, 0x08, 0x00, 0x07, 0x00, 0x00, 0x01, 0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
# elif LCDHEIGHT == 64
|
||||
static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0x7F, 0x7E, 0xFE, 0xFF, 0xFF, 0xFE, 0xFE, 0x7F, 0x7F, 0xFE, 0xFE, 0xFF, 0xFF, 0xFE, 0x7E, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xC0, 0xC0, 0xC0, 0xC0, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x88, 0x88, 0x88, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x99, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xF3, 0xF3, 0xE7, 0xE7, 0x00, 0x00, 0xE7, 0xE7, 0xF3, 0xF3, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x1F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x01, 0x01, 0x01, 0x01, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x80, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x00, 0x80, 0x01, 0x03, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x70, 0x88, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x00, 0x3C, 0xE0, 0xC0, 0x38, 0x1C, 0xE0, 0x80, 0x70, 0x0C, 0x00, 0xF8, 0xAC, 0x24, 0x24, 0x3C, 0x30, 0x00, 0x00, 0xFC, 0x0C, 0x04, 0x00, 0xF8, 0xAC, 0x24, 0x24, 0x2C, 0x30, 0x00, 0x70, 0xDC, 0x04, 0x04, 0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x8C, 0x04, 0x04, 0xF8, 0x00, 0x04, 0x3C, 0xE0, 0x80, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x83, 0x01, 0x01, 0x01, 0x81, 0xFE, 0x3C, 0x00, 0x00, 0xFF, 0x03, 0x0E, 0x70, 0xC0, 0xE0, 0x38, 0x06, 0x03, 0xFF, 0x00, 0x00, 0xFF, 0x18, 0x38, 0x66, 0xC3, 0x01, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
// TODO: generate bitmap of QMK logo here
|
||||
# endif
|
||||
#else
|
||||
//catchall for custom screen szies
|
||||
static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {0};
|
||||
// catchall for custom screen szies
|
||||
static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {0};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void micro_oled_init(void) {
|
||||
i2c_init();
|
||||
i2c_start(I2C_ADDRESS_SA0_1);
|
||||
i2c_init();
|
||||
i2c_start(I2C_ADDRESS_SA0_1);
|
||||
|
||||
// Display Init sequence for 64x48 OLED module
|
||||
send_command(DISPLAYOFF); // 0xAE
|
||||
// Display Init sequence for 64x48 OLED module
|
||||
send_command(DISPLAYOFF); // 0xAE
|
||||
|
||||
send_command(SETDISPLAYCLOCKDIV); // 0xD5
|
||||
send_command(0x80); // the suggested ratio 0x80
|
||||
send_command(SETDISPLAYCLOCKDIV); // 0xD5
|
||||
send_command(0x80); // the suggested ratio 0x80
|
||||
|
||||
send_command(SETMULTIPLEX); // 0xA8
|
||||
send_command(LCDHEIGHT - 1);
|
||||
send_command(SETMULTIPLEX); // 0xA8
|
||||
send_command(LCDHEIGHT - 1);
|
||||
|
||||
send_command(SETDISPLAYOFFSET); // 0xD3
|
||||
send_command(0x00); // no offset
|
||||
send_command(SETDISPLAYOFFSET); // 0xD3
|
||||
send_command(0x00); // no offset
|
||||
|
||||
send_command(SETSTARTLINE | 0x00); // line #0
|
||||
send_command(SETSTARTLINE | 0x00); // line #0
|
||||
|
||||
send_command(CHARGEPUMP); // enable charge pump
|
||||
send_command(0x14);
|
||||
send_command(CHARGEPUMP); // enable charge pump
|
||||
send_command(0x14);
|
||||
|
||||
send_command(NORMALDISPLAY); // 0xA6
|
||||
send_command(DISPLAYALLONRESUME); // 0xA4
|
||||
send_command(NORMALDISPLAY); // 0xA6
|
||||
send_command(DISPLAYALLONRESUME); // 0xA4
|
||||
|
||||
//display at regular orientation
|
||||
send_command(SEGREMAP | 0x1);
|
||||
send_command(COMSCANDEC);
|
||||
// display at regular orientation
|
||||
send_command(SEGREMAP | 0x1);
|
||||
send_command(COMSCANDEC);
|
||||
|
||||
//rotate display 180
|
||||
// rotate display 180
|
||||
#ifdef micro_oled_rotate_180
|
||||
send_command(SEGREMAP);
|
||||
send_command(COMSCANINC);
|
||||
send_command(SEGREMAP);
|
||||
send_command(COMSCANINC);
|
||||
#endif
|
||||
|
||||
send_command(MEMORYMODE);
|
||||
send_command(0x10);
|
||||
send_command(MEMORYMODE);
|
||||
send_command(0x10);
|
||||
|
||||
send_command(SETCOMPINS); // 0xDA
|
||||
if (LCDHEIGHT > 32) {
|
||||
send_command(0x12);
|
||||
} else {
|
||||
send_command(0x02);
|
||||
}
|
||||
send_command(SETCONTRAST); // 0x81
|
||||
send_command(0x8F);
|
||||
send_command(SETCOMPINS); // 0xDA
|
||||
if (LCDHEIGHT > 32) {
|
||||
send_command(0x12);
|
||||
} else {
|
||||
send_command(0x02);
|
||||
}
|
||||
send_command(SETCONTRAST); // 0x81
|
||||
send_command(0x8F);
|
||||
|
||||
send_command(SETPRECHARGE); // 0xd9
|
||||
send_command(0xF1);
|
||||
send_command(SETPRECHARGE); // 0xd9
|
||||
send_command(0xF1);
|
||||
|
||||
send_command(SETVCOMDESELECT); // 0xDB
|
||||
send_command(0x40);
|
||||
send_command(SETVCOMDESELECT); // 0xDB
|
||||
send_command(0x40);
|
||||
|
||||
send_command(DISPLAYON); //--turn on oled panel
|
||||
clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory.
|
||||
send_buffer();
|
||||
send_command(DISPLAYON); //--turn on oled panel
|
||||
clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory.
|
||||
send_buffer();
|
||||
}
|
||||
|
||||
void send_command(uint8_t command) {
|
||||
micro_oled_transfer_buffer[0] = I2C_COMMAND;
|
||||
micro_oled_transfer_buffer[1] = command;
|
||||
i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100);
|
||||
micro_oled_transfer_buffer[0] = I2C_COMMAND;
|
||||
micro_oled_transfer_buffer[1] = command;
|
||||
i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100);
|
||||
}
|
||||
|
||||
void send_data(uint8_t data) {
|
||||
micro_oled_transfer_buffer[0] = I2C_DATA;
|
||||
micro_oled_transfer_buffer[1] = data;
|
||||
i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100);
|
||||
micro_oled_transfer_buffer[0] = I2C_DATA;
|
||||
micro_oled_transfer_buffer[1] = data;
|
||||
i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100);
|
||||
}
|
||||
|
||||
/** \brief Set SSD1306 page address.
|
||||
Send page address command and address to the SSD1306 OLED controller.
|
||||
*/
|
||||
void set_page_address(uint8_t address) {
|
||||
address = (0xB0 | address);
|
||||
send_command(address);
|
||||
address = (0xB0 | address);
|
||||
send_command(address);
|
||||
}
|
||||
|
||||
/** \brief Set SSD1306 column address.
|
||||
Send column address command and address to the SSD1306 OLED controller.
|
||||
*/
|
||||
void set_column_address(uint8_t address) {
|
||||
send_command( ( 0x10 | (address >> 4) ) + ((128 - LCDWIDTH) >> 8) );
|
||||
send_command( 0x0F & address );
|
||||
send_command((0x10 | (address >> 4)) + ((128 - LCDWIDTH) >> 8));
|
||||
send_command(0x0F & address);
|
||||
}
|
||||
|
||||
/** \brief Clear SSD1306's memory.
|
||||
To clear GDRAM inside the LCD controller.
|
||||
*/
|
||||
void clear_screen(void) {
|
||||
for (int i=0;i<8; i++) {
|
||||
set_page_address(i);
|
||||
set_column_address(0);
|
||||
for (int j=0; j<0x80; j++) {
|
||||
send_data(0);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
set_page_address(i);
|
||||
set_column_address(0);
|
||||
for (int j = 0; j < 0x80; j++) {
|
||||
send_data(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Clear SSD1306's memory.
|
||||
To clear GDRAM inside the LCD controller.
|
||||
*/
|
||||
void clear_buffer(void) {
|
||||
//384
|
||||
memset(micro_oled_screen_buffer, 0, LCDWIDTH*LCDWIDTH/8);
|
||||
// 384
|
||||
memset(micro_oled_screen_buffer, 0, LCDWIDTH * LCDWIDTH / 8);
|
||||
}
|
||||
|
||||
/** \brief Invert display.
|
||||
The PIXEL_ON color of the display will turn to PIXEL_OFF and the PIXEL_OFF will turn to PIXEL_ON.
|
||||
*/
|
||||
void invert_screen(bool invert) {
|
||||
if (invert) {
|
||||
send_command(INVERTDISPLAY);
|
||||
} else {
|
||||
send_command(NORMALDISPLAY);
|
||||
}
|
||||
if (invert) {
|
||||
send_command(INVERTDISPLAY);
|
||||
} else {
|
||||
send_command(NORMALDISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Set contrast.
|
||||
OLED contract value from 0 to 255. Note: Contrast level is not very obvious.
|
||||
*/
|
||||
void set_contrast(uint8_t contrast) {
|
||||
send_command(SETCONTRAST); // 0x81
|
||||
send_command(contrast);
|
||||
send_command(SETCONTRAST); // 0x81
|
||||
send_command(contrast);
|
||||
}
|
||||
|
||||
/** \brief Transfer display buffer.
|
||||
Sends the updated buffer to the controller - the current status is checked before to save i2c exectution time
|
||||
*/
|
||||
void send_buffer(void) {
|
||||
uint8_t i, j;
|
||||
uint8_t i, j;
|
||||
|
||||
uint8_t page_addr = 0xFF;
|
||||
for (i = 0; i < LCDHEIGHT/8; i++) {
|
||||
uint8_t col_addr = 0xFF;
|
||||
for (j = 0; j < LCDWIDTH; j++) {
|
||||
if (micro_oled_screen_buffer[i*LCDWIDTH+j] != micro_oled_screen_current[i*LCDWIDTH+j]) {
|
||||
if (page_addr != i) {
|
||||
set_page_address(i);
|
||||
uint8_t page_addr = 0xFF;
|
||||
for (i = 0; i < LCDHEIGHT / 8; i++) {
|
||||
uint8_t col_addr = 0xFF;
|
||||
for (j = 0; j < LCDWIDTH; j++) {
|
||||
if (micro_oled_screen_buffer[i * LCDWIDTH + j] != micro_oled_screen_current[i * LCDWIDTH + j]) {
|
||||
if (page_addr != i) {
|
||||
set_page_address(i);
|
||||
}
|
||||
if (col_addr != j) {
|
||||
set_column_address(j);
|
||||
}
|
||||
send_data(micro_oled_screen_buffer[i * LCDWIDTH + j]);
|
||||
micro_oled_screen_current[i * LCDWIDTH + j] = micro_oled_screen_buffer[i * LCDWIDTH + j];
|
||||
col_addr = j + 1;
|
||||
}
|
||||
}
|
||||
if (col_addr != j) {
|
||||
set_column_address(j);
|
||||
}
|
||||
send_data(micro_oled_screen_buffer[i*LCDWIDTH+j]);
|
||||
micro_oled_screen_current[i*LCDWIDTH+j] = micro_oled_screen_buffer[i*LCDWIDTH+j];
|
||||
col_addr = j + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Draw pixel with color and mode.
|
||||
Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode.
|
||||
*/
|
||||
void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode) {
|
||||
if ((x<0) || (x>=LCDWIDTH) || (y<0) || (y>=LCDHEIGHT))
|
||||
return;
|
||||
if ((x < 0) || (x >= LCDWIDTH) || (y < 0) || (y >= LCDHEIGHT)) return;
|
||||
|
||||
if (mode == XOR) {
|
||||
if (color == PIXEL_ON)
|
||||
micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] ^= _BV((y%8));
|
||||
} else {
|
||||
if (color == PIXEL_ON)
|
||||
micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] |= _BV((y%8));
|
||||
else
|
||||
micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] &= ~_BV((y%8));
|
||||
}
|
||||
if (mode == XOR) {
|
||||
if (color == PIXEL_ON) micro_oled_screen_buffer[x + (y / 8) * LCDWIDTH] ^= _BV((y % 8));
|
||||
} else {
|
||||
if (color == PIXEL_ON)
|
||||
micro_oled_screen_buffer[x + (y / 8) * LCDWIDTH] |= _BV((y % 8));
|
||||
else
|
||||
micro_oled_screen_buffer[x + (y / 8) * LCDWIDTH] &= ~_BV((y % 8));
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Draw line with color and mode.
|
||||
Draw line using color and mode from x0,y0 to x1,y1 of the screen buffer.
|
||||
*/
|
||||
void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color, uint8_t mode) {
|
||||
uint8_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||
if (steep) {
|
||||
swap(x0, y0);
|
||||
swap(x1, y1);
|
||||
}
|
||||
|
||||
if (x0 > x1) {
|
||||
swap(x0, x1);
|
||||
swap(y0, y1);
|
||||
}
|
||||
|
||||
uint8_t dx, dy;
|
||||
dx = x1 - x0;
|
||||
dy = abs(y1 - y0);
|
||||
|
||||
int8_t err = dx / 2;
|
||||
int8_t ystep;
|
||||
|
||||
if (y0 < y1) {
|
||||
ystep = 1;
|
||||
} else {
|
||||
ystep = -1;}
|
||||
|
||||
for (; x0<x1; x0++) {
|
||||
uint8_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||
if (steep) {
|
||||
draw_pixel(y0, x0, color, mode);
|
||||
swap(x0, y0);
|
||||
swap(x1, y1);
|
||||
}
|
||||
|
||||
if (x0 > x1) {
|
||||
swap(x0, x1);
|
||||
swap(y0, y1);
|
||||
}
|
||||
|
||||
uint8_t dx, dy;
|
||||
dx = x1 - x0;
|
||||
dy = abs(y1 - y0);
|
||||
|
||||
int8_t err = dx / 2;
|
||||
int8_t ystep;
|
||||
|
||||
if (y0 < y1) {
|
||||
ystep = 1;
|
||||
} else {
|
||||
draw_pixel(x0, y0, color, mode);
|
||||
ystep = -1;
|
||||
}
|
||||
err -= dy;
|
||||
if (err < 0) {
|
||||
y0 += ystep;
|
||||
err += dx;
|
||||
|
||||
for (; x0 < x1; x0++) {
|
||||
if (steep) {
|
||||
draw_pixel(y0, x0, color, mode);
|
||||
} else {
|
||||
draw_pixel(x0, y0, color, mode);
|
||||
}
|
||||
err -= dy;
|
||||
if (err < 0) {
|
||||
y0 += ystep;
|
||||
err += dx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Draw horizontal line with color and mode.
|
||||
Draw horizontal line using color and mode from x,y to x+width,y of the screen buffer.
|
||||
*/
|
||||
void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode) {
|
||||
draw_line(x,y,x+width,y,color,mode);
|
||||
}
|
||||
void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode) { draw_line(x, y, x + width, y, color, mode); }
|
||||
|
||||
/** \brief Draw vertical line.
|
||||
Draw vertical line using current fore color and current draw mode from x,y to x,y+height of the screen buffer.
|
||||
*/
|
||||
void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode) {
|
||||
draw_line(x,y,x,y+height,color,mode);
|
||||
}
|
||||
void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode) { draw_line(x, y, x, y + height, color, mode); }
|
||||
|
||||
/** \brief Draw rectangle with color and mode.
|
||||
Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||
*/
|
||||
void draw_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||
uint8_t tempHeight;
|
||||
uint8_t tempHeight;
|
||||
|
||||
draw_line_hori(x,y, width, color, mode);
|
||||
draw_line_hori(x,y+height-1, width, color, mode);
|
||||
draw_line_hori(x, y, width, color, mode);
|
||||
draw_line_hori(x, y + height - 1, width, color, mode);
|
||||
|
||||
tempHeight=height-2;
|
||||
tempHeight = height - 2;
|
||||
|
||||
// skip drawing vertical lines to avoid overlapping of pixel that will
|
||||
// affect XOR plot if no pixel in between horizontal lines
|
||||
if (tempHeight<1) return;
|
||||
// skip drawing vertical lines to avoid overlapping of pixel that will
|
||||
// affect XOR plot if no pixel in between horizontal lines
|
||||
if (tempHeight < 1) return;
|
||||
|
||||
draw_line_vert(x,y+1, tempHeight, color, mode);
|
||||
draw_line_vert(x+width-1, y+1, tempHeight, color, mode);
|
||||
draw_line_vert(x, y + 1, tempHeight, color, mode);
|
||||
draw_line_vert(x + width - 1, y + 1, tempHeight, color, mode);
|
||||
}
|
||||
|
||||
/** \brief Draw rectangle with color and mode.
|
||||
Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||
*/
|
||||
void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||
uint8_t tempHeight;
|
||||
uint8_t tempHeight;
|
||||
|
||||
draw_line_hori(x+1,y, width-2, color, mode);
|
||||
draw_line_hori(x+1,y+height-1, width-2, color, mode);
|
||||
draw_line_hori(x + 1, y, width - 2, color, mode);
|
||||
draw_line_hori(x + 1, y + height - 1, width - 2, color, mode);
|
||||
|
||||
tempHeight=height-2;
|
||||
tempHeight = height - 2;
|
||||
|
||||
// skip drawing vertical lines to avoid overlapping of pixel that will
|
||||
// affect XOR plot if no pixel in between horizontal lines
|
||||
if (tempHeight<1) return;
|
||||
// skip drawing vertical lines to avoid overlapping of pixel that will
|
||||
// affect XOR plot if no pixel in between horizontal lines
|
||||
if (tempHeight < 1) return;
|
||||
|
||||
draw_line_vert(x,y+1, tempHeight, color, mode);
|
||||
draw_line_vert(x+width-1, y+1, tempHeight, color, mode);
|
||||
draw_line_vert(x, y + 1, tempHeight, color, mode);
|
||||
draw_line_vert(x + width - 1, y + 1, tempHeight, color, mode);
|
||||
}
|
||||
|
||||
/** \brief Draw filled rectangle with color and mode.
|
||||
Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||
*/
|
||||
void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||
// TODO - need to optimise the memory map draw so that this function will not call pixel one by one
|
||||
for (int i=x; i<x+width;i++) {
|
||||
draw_line_vert(i,y, height, color, mode);
|
||||
}
|
||||
// TODO - need to optimise the memory map draw so that this function will not call pixel one by one
|
||||
for (int i = x; i < x + width; i++) {
|
||||
draw_line_vert(i, y, height, color, mode);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Draw filled rectangle with color and mode.
|
||||
Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||
*/
|
||||
void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||
// TODO - need to optimise the memory map draw so that this function will not call pixel one by one
|
||||
for (int i=x; i<x+width;i++) {
|
||||
if (i == x || i == (x + width - 1))
|
||||
draw_line_vert(i, y+1, height-2, color, mode);
|
||||
else
|
||||
draw_line_vert(i, y, height, color, mode);
|
||||
}
|
||||
// TODO - need to optimise the memory map draw so that this function will not call pixel one by one
|
||||
for (int i = x; i < x + width; i++) {
|
||||
if (i == x || i == (x + width - 1))
|
||||
draw_line_vert(i, y + 1, height - 2, color, mode);
|
||||
else
|
||||
draw_line_vert(i, y, height, color, mode);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Draw character with color and mode.
|
||||
Draw character c using color and draw mode at x,y.
|
||||
*/
|
||||
void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font) {
|
||||
// TODO - New routine to take font of any height, at the moment limited to font height in multiple of 8 pixels
|
||||
// TODO - New routine to take font of any height, at the moment limited to font height in multiple of 8 pixels
|
||||
|
||||
uint8_t rowsToDraw,row, tempC;
|
||||
uint8_t i,j,temp;
|
||||
uint16_t charPerBitmapRow,charColPositionOnBitmap,charRowPositionOnBitmap,charBitmapStartPosition;
|
||||
uint8_t rowsToDraw, row, tempC;
|
||||
uint8_t i, j, temp;
|
||||
uint16_t charPerBitmapRow, charColPositionOnBitmap, charRowPositionOnBitmap, charBitmapStartPosition;
|
||||
|
||||
if ((font>=TOTALFONTS) || (font<0))
|
||||
return;
|
||||
if ((font >= TOTALFONTS) || (font < 0)) return;
|
||||
|
||||
uint8_t fontType = font;
|
||||
uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType]+0);
|
||||
uint8_t fontHeight = pgm_read_byte(fonts_pointer[fontType]+1);
|
||||
uint8_t fontStartChar = pgm_read_byte(fonts_pointer[fontType]+2);
|
||||
uint8_t fontTotalChar = pgm_read_byte(fonts_pointer[fontType]+3);
|
||||
uint16_t fontMapWidth = (pgm_read_byte(fonts_pointer[fontType]+4)*100)+pgm_read_byte(fonts_pointer[fontType]+5); // two bytes values into integer 16
|
||||
uint8_t fontType = font;
|
||||
uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType] + 0);
|
||||
uint8_t fontHeight = pgm_read_byte(fonts_pointer[fontType] + 1);
|
||||
uint8_t fontStartChar = pgm_read_byte(fonts_pointer[fontType] + 2);
|
||||
uint8_t fontTotalChar = pgm_read_byte(fonts_pointer[fontType] + 3);
|
||||
uint16_t fontMapWidth = (pgm_read_byte(fonts_pointer[fontType] + 4) * 100) + pgm_read_byte(fonts_pointer[fontType] + 5); // two bytes values into integer 16
|
||||
|
||||
if ((c<fontStartChar) || (c>(fontStartChar+fontTotalChar-1))) // no bitmap for the required c
|
||||
return;
|
||||
if ((c < fontStartChar) || (c > (fontStartChar + fontTotalChar - 1))) // no bitmap for the required c
|
||||
return;
|
||||
|
||||
tempC=c-fontStartChar;
|
||||
tempC = c - fontStartChar;
|
||||
|
||||
// each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn
|
||||
rowsToDraw=fontHeight/8; // 8 is LCD's page size, see SSD1306 datasheet
|
||||
if (rowsToDraw<=1) rowsToDraw=1;
|
||||
// each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn
|
||||
rowsToDraw = fontHeight / 8; // 8 is LCD's page size, see SSD1306 datasheet
|
||||
if (rowsToDraw <= 1) rowsToDraw = 1;
|
||||
|
||||
// the following draw function can draw anywhere on the screen, but SLOW pixel by pixel draw
|
||||
if (rowsToDraw==1) {
|
||||
for (i=0;i<fontWidth+1;i++) {
|
||||
if (i==fontWidth) // this is done in a weird way because for 5x7 font, there is no margin, this code add a margin after col 5
|
||||
temp=0;
|
||||
else
|
||||
temp=pgm_read_byte(fonts_pointer[fontType]+FONTHEADERSIZE+(tempC*fontWidth)+i);
|
||||
// the following draw function can draw anywhere on the screen, but SLOW pixel by pixel draw
|
||||
if (rowsToDraw == 1) {
|
||||
for (i = 0; i < fontWidth + 1; i++) {
|
||||
if (i == fontWidth) // this is done in a weird way because for 5x7 font, there is no margin, this code add a margin after col 5
|
||||
temp = 0;
|
||||
else
|
||||
temp = pgm_read_byte(fonts_pointer[fontType] + FONTHEADERSIZE + (tempC * fontWidth) + i);
|
||||
|
||||
for (j=0;j<8;j++) { // 8 is the LCD's page height (see datasheet for explanation)
|
||||
if (temp & 0x1) {
|
||||
draw_pixel(x+i, y+j, color,mode);
|
||||
for (j = 0; j < 8; j++) { // 8 is the LCD's page height (see datasheet for explanation)
|
||||
if (temp & 0x1) {
|
||||
draw_pixel(x + i, y + j, color, mode);
|
||||
} else {
|
||||
draw_pixel(x + i, y + j, !color, mode);
|
||||
}
|
||||
|
||||
temp >>= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
draw_pixel(x+i, y+j, !color,mode);
|
||||
}
|
||||
|
||||
temp >>=1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// font height over 8 bit
|
||||
// take character "0" ASCII 48 as example
|
||||
charPerBitmapRow = fontMapWidth/fontWidth; // 256/8 =32 char per row
|
||||
charColPositionOnBitmap = tempC % charPerBitmapRow; // =16
|
||||
charRowPositionOnBitmap = (int)(tempC/charPerBitmapRow); // =1
|
||||
charBitmapStartPosition = (charRowPositionOnBitmap * fontMapWidth * (fontHeight/8)) + (charColPositionOnBitmap * fontWidth) ;
|
||||
// font height over 8 bit
|
||||
// take character "0" ASCII 48 as example
|
||||
charPerBitmapRow = fontMapWidth / fontWidth; // 256/8 =32 char per row
|
||||
charColPositionOnBitmap = tempC % charPerBitmapRow; // =16
|
||||
charRowPositionOnBitmap = (int)(tempC / charPerBitmapRow); // =1
|
||||
charBitmapStartPosition = (charRowPositionOnBitmap * fontMapWidth * (fontHeight / 8)) + (charColPositionOnBitmap * fontWidth);
|
||||
|
||||
// each row on LCD is 8 bit height (see datasheet for explanation)
|
||||
for(row=0;row<rowsToDraw;row++) {
|
||||
for (i=0; i<fontWidth;i++) {
|
||||
temp=pgm_read_byte(fonts_pointer[fontType]+FONTHEADERSIZE+(charBitmapStartPosition+i+(row*fontMapWidth)));
|
||||
for (j=0;j<8;j++) { // 8 is the LCD's page height (see datasheet for explanation)
|
||||
if (temp & 0x1) {
|
||||
draw_pixel(x+i,y+j+(row*8), color, mode);
|
||||
// each row on LCD is 8 bit height (see datasheet for explanation)
|
||||
for (row = 0; row < rowsToDraw; row++) {
|
||||
for (i = 0; i < fontWidth; i++) {
|
||||
temp = pgm_read_byte(fonts_pointer[fontType] + FONTHEADERSIZE + (charBitmapStartPosition + i + (row * fontMapWidth)));
|
||||
for (j = 0; j < 8; j++) { // 8 is the LCD's page height (see datasheet for explanation)
|
||||
if (temp & 0x1) {
|
||||
draw_pixel(x + i, y + j + (row * 8), color, mode);
|
||||
} else {
|
||||
draw_pixel(x + i, y + j + (row * 8), !color, mode);
|
||||
}
|
||||
temp >>= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
draw_pixel(x+i,y+j+(row*8), !color, mode);
|
||||
}
|
||||
temp >>=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font) {
|
||||
void draw_string(uint8_t x, uint8_t y, char* string, uint8_t color, uint8_t mode, uint8_t font) {
|
||||
if ((font >= TOTALFONTS) || (font < 0)) return;
|
||||
|
||||
if ((font>=TOTALFONTS) || (font<0))
|
||||
return;
|
||||
|
||||
uint8_t fontType = font;
|
||||
uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType]+0);
|
||||
|
||||
uint8_t cur_x = x;
|
||||
for (int i = 0; i < strlen(string); i++) {
|
||||
draw_char(cur_x, y, string[i], color, mode, font);
|
||||
cur_x += fontWidth + 1;
|
||||
}
|
||||
uint8_t fontType = font;
|
||||
uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType] + 0);
|
||||
|
||||
uint8_t cur_x = x;
|
||||
for (int i = 0; i < strlen(string); i++) {
|
||||
draw_char(cur_x, y, string[i], color, mode, font);
|
||||
cur_x += fontWidth + 1;
|
||||
}
|
||||
}
|
||||
|
@ -49,86 +49,86 @@ void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t
|
||||
void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode);
|
||||
void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode);
|
||||
void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font);
|
||||
void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font);
|
||||
void draw_string(uint8_t x, uint8_t y, char* string, uint8_t color, uint8_t mode, uint8_t font);
|
||||
|
||||
#define I2C_ADDRESS_SA0_0 0b0111100
|
||||
#ifndef I2C_ADDRESS_SA0_1
|
||||
#define I2C_ADDRESS_SA0_1 0b0111101
|
||||
# define I2C_ADDRESS_SA0_1 0b0111101
|
||||
#endif
|
||||
#define I2C_COMMAND 0x00
|
||||
#define I2C_DATA 0x40
|
||||
#define PIXEL_OFF 0
|
||||
#define PIXEL_ON 1
|
||||
#define PIXEL_ON 1
|
||||
|
||||
#ifndef LCDWIDTH
|
||||
#define LCDWIDTH 64
|
||||
# define LCDWIDTH 64
|
||||
#endif
|
||||
#ifndef LCDWIDTH
|
||||
#define LCDHEIGHT 48
|
||||
# define LCDHEIGHT 48
|
||||
#endif
|
||||
#define FONTHEADERSIZE 6
|
||||
#define FONTHEADERSIZE 6
|
||||
|
||||
#define NORM 0
|
||||
#define XOR 1
|
||||
#define NORM 0
|
||||
#define XOR 1
|
||||
|
||||
#define PAGE 0
|
||||
#define ALL 1
|
||||
#define PAGE 0
|
||||
#define ALL 1
|
||||
|
||||
#define WIDGETSTYLE0 0
|
||||
#define WIDGETSTYLE1 1
|
||||
#define WIDGETSTYLE2 2
|
||||
#define WIDGETSTYLE0 0
|
||||
#define WIDGETSTYLE1 1
|
||||
#define WIDGETSTYLE2 2
|
||||
|
||||
#define SETCONTRAST 0x81
|
||||
#define DISPLAYALLONRESUME 0xA4
|
||||
#define DISPLAYALLON 0xA5
|
||||
#define NORMALDISPLAY 0xA6
|
||||
#define INVERTDISPLAY 0xA7
|
||||
#define DISPLAYOFF 0xAE
|
||||
#define DISPLAYON 0xAF
|
||||
#define SETDISPLAYOFFSET 0xD3
|
||||
#define SETCOMPINS 0xDA
|
||||
#define SETVCOMDESELECT 0xDB
|
||||
#define SETDISPLAYCLOCKDIV 0xD5
|
||||
#define SETPRECHARGE 0xD9
|
||||
#define SETMULTIPLEX 0xA8
|
||||
#define SETLOWCOLUMN 0x00
|
||||
#define SETHIGHCOLUMN 0x10
|
||||
#define SETSTARTLINE 0x40
|
||||
#define MEMORYMODE 0x20
|
||||
#define COMSCANINC 0xC0
|
||||
#define COMSCANDEC 0xC8
|
||||
#define SEGREMAP 0xA0
|
||||
#define CHARGEPUMP 0x8D
|
||||
#define EXTERNALVCC 0x01
|
||||
#define SWITCHCAPVCC 0x02
|
||||
#define SETCONTRAST 0x81
|
||||
#define DISPLAYALLONRESUME 0xA4
|
||||
#define DISPLAYALLON 0xA5
|
||||
#define NORMALDISPLAY 0xA6
|
||||
#define INVERTDISPLAY 0xA7
|
||||
#define DISPLAYOFF 0xAE
|
||||
#define DISPLAYON 0xAF
|
||||
#define SETDISPLAYOFFSET 0xD3
|
||||
#define SETCOMPINS 0xDA
|
||||
#define SETVCOMDESELECT 0xDB
|
||||
#define SETDISPLAYCLOCKDIV 0xD5
|
||||
#define SETPRECHARGE 0xD9
|
||||
#define SETMULTIPLEX 0xA8
|
||||
#define SETLOWCOLUMN 0x00
|
||||
#define SETHIGHCOLUMN 0x10
|
||||
#define SETSTARTLINE 0x40
|
||||
#define MEMORYMODE 0x20
|
||||
#define COMSCANINC 0xC0
|
||||
#define COMSCANDEC 0xC8
|
||||
#define SEGREMAP 0xA0
|
||||
#define CHARGEPUMP 0x8D
|
||||
#define EXTERNALVCC 0x01
|
||||
#define SWITCHCAPVCC 0x02
|
||||
|
||||
// Scroll
|
||||
#define ACTIVATESCROLL 0x2F
|
||||
#define DEACTIVATESCROLL 0x2E
|
||||
#define SETVERTICALSCROLLAREA 0xA3
|
||||
#define RIGHTHORIZONTALSCROLL 0x26
|
||||
#define LEFT_HORIZONTALSCROLL 0x27
|
||||
#define ACTIVATESCROLL 0x2F
|
||||
#define DEACTIVATESCROLL 0x2E
|
||||
#define SETVERTICALSCROLLAREA 0xA3
|
||||
#define RIGHTHORIZONTALSCROLL 0x26
|
||||
#define LEFT_HORIZONTALSCROLL 0x27
|
||||
#define VERTICALRIGHTHORIZONTALSCROLL 0x29
|
||||
#define VERTICALLEFTHORIZONTALSCROLL 0x2A
|
||||
#define VERTICALLEFTHORIZONTALSCROLL 0x2A
|
||||
|
||||
typedef enum CMD {
|
||||
CMD_CLEAR, //0
|
||||
CMD_INVERT, //1
|
||||
CMD_CONTRAST, //2
|
||||
CMD_DISPLAY, //3
|
||||
CMD_SETCURSOR, //4
|
||||
CMD_PIXEL, //5
|
||||
CMD_LINE, //6
|
||||
CMD_LINEH, //7
|
||||
CMD_LINEV, //8
|
||||
CMD_RECT, //9
|
||||
CMD_RECTFILL, //10
|
||||
CMD_CIRCLE, //11
|
||||
CMD_CIRCLEFILL, //12
|
||||
CMD_DRAWCHAR, //13
|
||||
CMD_DRAWBITMAP, //14
|
||||
CMD_GETLCDWIDTH, //15
|
||||
CMD_GETLCDHEIGHT, //16
|
||||
CMD_SETCOLOR, //17
|
||||
CMD_SETDRAWMODE //18
|
||||
CMD_CLEAR, // 0
|
||||
CMD_INVERT, // 1
|
||||
CMD_CONTRAST, // 2
|
||||
CMD_DISPLAY, // 3
|
||||
CMD_SETCURSOR, // 4
|
||||
CMD_PIXEL, // 5
|
||||
CMD_LINE, // 6
|
||||
CMD_LINEH, // 7
|
||||
CMD_LINEV, // 8
|
||||
CMD_RECT, // 9
|
||||
CMD_RECTFILL, // 10
|
||||
CMD_CIRCLE, // 11
|
||||
CMD_CIRCLEFILL, // 12
|
||||
CMD_DRAWCHAR, // 13
|
||||
CMD_DRAWBITMAP, // 14
|
||||
CMD_GETLCDWIDTH, // 15
|
||||
CMD_GETLCDHEIGHT, // 16
|
||||
CMD_SETCOLOR, // 17
|
||||
CMD_SETDRAWMODE // 18
|
||||
} commCommand_t;
|
@ -16,16 +16,16 @@
|
||||
#include "qwiic.h"
|
||||
|
||||
void qwiic_init(void) {
|
||||
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||
joystiic_init();
|
||||
#endif
|
||||
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||
#endif
|
||||
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||
micro_oled_init();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void qwiic_task(void) {
|
||||
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||
joystiic_task();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -18,10 +18,10 @@
|
||||
#include "i2c_master.h"
|
||||
|
||||
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||
#include "joystiic.h"
|
||||
# include "joystiic.h"
|
||||
#endif
|
||||
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||
#include "micro_oled.h"
|
||||
# include "micro_oled.h"
|
||||
#endif
|
||||
|
||||
void qwiic_init(void);
|
||||
|
@ -29,260 +29,11 @@ https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
|
||||
// Standard ASCII 5x7 font
|
||||
static const unsigned char font5x7[] PROGMEM = {
|
||||
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
|
||||
5,8,0,255,12,75,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x21, 0x54, 0x54, 0x78, 0x41,
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0xF0, 0x29, 0x24, 0x29, 0xF0,
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x32, 0x48, 0x48, 0x48, 0x32,
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x39, 0x44, 0x44, 0x44, 0x39,
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0xAA, 0x00, 0x55, 0x00, 0xAA,
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0x7C, 0x2A, 0x2A, 0x3E, 0x14,
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
5, 8, 0, 255, 12, 75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02,
|
||||
0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40,
|
||||
0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23,
|
||||
0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x21, 0x54, 0x54, 0x78, 0x41, 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0xF0, 0x29, 0x24, 0x29, 0xF0, 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x32, 0x48, 0x48, 0x48, 0x32, 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x39, 0x44, 0x44, 0x44, 0x39, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09,
|
||||
0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0xAA, 0x00, 0x55, 0x00, 0xAA, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0x7C,
|
||||
0x2A, 0x2A, 0x3E, 0x14, 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
@ -27,101 +27,13 @@ https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
|
||||
|
||||
static const unsigned char font8x16[] PROGMEM = {
|
||||
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
|
||||
8,16,32,96,2,56,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xBE, 0x90, 0xD0, 0xBE, 0x90, 0x00,
|
||||
0x00, 0x1C, 0x62, 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x0C, 0x12, 0x92, 0x4C, 0xB0, 0x88, 0x06, 0x00,
|
||||
0x80, 0x7C, 0x62, 0xB2, 0x1C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xE0, 0x18, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00,
|
||||
0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, 0x00, 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00,
|
||||
0xF8, 0x04, 0xC2, 0x32, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x04, 0x04, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00,
|
||||
0xC0, 0xA0, 0x98, 0x84, 0xFE, 0x80, 0x80, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x22, 0xC2, 0x00, 0x00,
|
||||
0xF8, 0x44, 0x22, 0x22, 0x22, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00,
|
||||
0x00, 0x8C, 0x52, 0x22, 0x52, 0x8C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0xF8, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||
0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x00, 0x04, 0x04, 0x0F, 0x04, 0x03, 0x00, 0x00, 0x04, 0x02, 0x01, 0x03, 0x04, 0x04, 0x03, 0x00,
|
||||
0x03, 0x04, 0x04, 0x04, 0x05, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x06, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x06, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x03, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||
0x01, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
|
||||
0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF8, 0x04, 0x72, 0x8A, 0xFA, 0x84, 0x78, 0x00, 0x00, 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
|
||||
0xFE, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x22, 0xE2, 0x00, 0x00,
|
||||
0xFE, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0xFE, 0x40, 0xB0, 0x08, 0x04, 0x02, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0C, 0x70, 0x80, 0x70, 0x0C, 0xFE, 0x00,
|
||||
0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xFE, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00,
|
||||
0xFE, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x42, 0x42, 0xA2, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x42, 0x42, 0x80, 0x00, 0x00,
|
||||
0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00,
|
||||
0x06, 0x38, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x3E, 0xC0, 0xF0, 0x0E, 0xF0, 0xC0, 0x3E, 0x00,
|
||||
0x00, 0x06, 0x98, 0x60, 0x98, 0x06, 0x00, 0x00, 0x00, 0x06, 0x18, 0xE0, 0x18, 0x06, 0x00, 0x00,
|
||||
0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x02, 0x00,
|
||||
0x00, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00,
|
||||
0x40, 0x30, 0x0C, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x02, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x00,
|
||||
0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||
0x07, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00,
|
||||
0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x12, 0x11, 0x10, 0x00,
|
||||
0x00, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
|
||||
0x00, 0x06, 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||
0x00, 0xE0, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00,
|
||||
0x00, 0x20, 0xFC, 0x22, 0x22, 0x22, 0x02, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00,
|
||||
0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00,
|
||||
0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0xF0, 0x20, 0x10, 0xF0, 0x00,
|
||||
0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xE0, 0x00, 0x00,
|
||||
0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00,
|
||||
0x00, 0xF0, 0x20, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x20, 0x00, 0x00,
|
||||
0x00, 0x20, 0x20, 0xFC, 0x20, 0x20, 0x20, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00,
|
||||
0x00, 0x70, 0x80, 0x00, 0x80, 0x70, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xF0, 0x00,
|
||||
0x00, 0x30, 0xC0, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00,
|
||||
0x00, 0x10, 0x10, 0x90, 0x50, 0x30, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x02, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x7E, 0x80, 0x80, 0x00, 0x00,
|
||||
0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00,
|
||||
0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x24, 0x24, 0x22, 0x1F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00,
|
||||
0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00,
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||
0x00, 0x3F, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x3F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x01, 0x06, 0x01, 0x00,
|
||||
0x00, 0x06, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x20, 0x20, 0x31, 0x0E, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
8, 16, 32, 96, 2, 56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xBE, 0x90, 0xD0, 0xBE, 0x90, 0x00, 0x00, 0x1C, 0x62, 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x0C, 0x12, 0x92, 0x4C, 0xB0, 0x88, 0x06, 0x00, 0x80, 0x7C, 0x62, 0xB2, 0x1C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x18, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00, 0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, 0x00, 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 0xF8, 0x04, 0xC2, 0x32, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x04, 0x04, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22,
|
||||
0x1C, 0x00, 0x00, 0x00, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xC0, 0xA0, 0x98, 0x84, 0xFE, 0x80, 0x80, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x22, 0xC2, 0x00, 0x00, 0xF8, 0x44, 0x22, 0x22, 0x22, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x8C, 0x52, 0x22, 0x52, 0x8C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x0F, 0x04, 0x03, 0x00, 0x00, 0x04, 0x02, 0x01, 0x03, 0x04, 0x04, 0x03, 0x00,
|
||||
0x03, 0x04, 0x04, 0x04, 0x05, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04,
|
||||
0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x04, 0x72, 0x8A, 0xFA, 0x84, 0x78, 0x00, 0x00, 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x22, 0xE2, 0x00, 0x00, 0xFE, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0xFE, 0x40, 0xB0, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFE, 0x0C, 0x70, 0x80, 0x70, 0x0C, 0xFE, 0x00, 0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xFE, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0xFE, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x42, 0x42, 0xA2, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x42, 0x42, 0x80, 0x00, 0x00, 0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x06, 0x38, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x3E, 0xC0, 0xF0, 0x0E, 0xF0, 0xC0, 0x3E, 0x00, 0x00, 0x06, 0x98, 0x60, 0x98, 0x06, 0x00, 0x00, 0x00, 0x06, 0x18, 0xE0, 0x18, 0x06, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x40, 0x30, 0x0C, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x12, 0x11, 0x10, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,
|
||||
0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00, 0x00, 0x20, 0xFC, 0x22, 0x22, 0x22, 0x02,
|
||||
0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0xF0, 0x20, 0x10, 0xF0, 0x00, 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0xFC, 0x20, 0x20, 0x20, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x70, 0x80, 0x00, 0x80, 0x70, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x30, 0xC0, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x10,
|
||||
0x10, 0x90, 0x50, 0x30, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x7E, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x24, 0x24, 0x22, 0x1F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00,
|
||||
0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x3F, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x3F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x06, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x20, 0x20, 0x31, 0x0E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
@ -19,54 +19,53 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define _GDISP_LLD_BOARD_H
|
||||
|
||||
static const I2CConfig i2ccfg = {
|
||||
400000 // clock speed (Hz); 400kHz max for IS31
|
||||
400000 // clock speed (Hz); 400kHz max for IS31
|
||||
};
|
||||
|
||||
static const uint8_t led_mask[] = {
|
||||
0xFF, 0x00, /* C1-1 -> C1-16 */
|
||||
0xFF, 0x00, /* C2-1 -> C2-16 */
|
||||
0xFF, 0x00, /* C3-1 -> C3-16 */
|
||||
0xFF, 0x00, /* C4-1 -> C4-16 */
|
||||
0x3F, 0x00, /* C5-1 -> C5-16 */
|
||||
0x00, 0x00, /* C6-1 -> C6-16 */
|
||||
0x00, 0x00, /* C7-1 -> C7-16 */
|
||||
0x00, 0x00, /* C8-1 -> C8-16 */
|
||||
0x00, 0x00, /* C9-1 -> C9-16 */
|
||||
0xFF, 0x00, /* C1-1 -> C1-16 */
|
||||
0xFF, 0x00, /* C2-1 -> C2-16 */
|
||||
0xFF, 0x00, /* C3-1 -> C3-16 */
|
||||
0xFF, 0x00, /* C4-1 -> C4-16 */
|
||||
0x3F, 0x00, /* C5-1 -> C5-16 */
|
||||
0x00, 0x00, /* C6-1 -> C6-16 */
|
||||
0x00, 0x00, /* C7-1 -> C7-16 */
|
||||
0x00, 0x00, /* C8-1 -> C8-16 */
|
||||
0x00, 0x00, /* C9-1 -> C9-16 */
|
||||
};
|
||||
|
||||
// The address of the LED
|
||||
#define LA(c, r) (c + r * 16 )
|
||||
#define LA(c, r) (c + r * 16)
|
||||
// Need to be an address that is not mapped, but inside the range of the controller matrix
|
||||
#define NA LA(8, 8)
|
||||
|
||||
// The numbers in the comments are the led numbers DXX on the PCB
|
||||
// The mapping is taken from the schematic of left hand side
|
||||
static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = {
|
||||
// 45 44 43 42 41 40 39
|
||||
{ LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
|
||||
// 52 51 50 49 48 47 46
|
||||
{ LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) },
|
||||
// 58 57 56 55 54 53 N/A
|
||||
{ LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA },
|
||||
// 67 66 65 64 63 62 61
|
||||
{ LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) },
|
||||
// 76 75 74 73 72 60 59
|
||||
{ LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) },
|
||||
// N/A N/A N/A N/A N/A N/A 68
|
||||
{ NA, NA, NA, NA, NA, NA, LA(5, 4) },
|
||||
// N/A N/A N/A N/A 71 70 69
|
||||
{ NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0) },
|
||||
// 45 44 43 42 41 40 39
|
||||
{LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
|
||||
// 52 51 50 49 48 47 46
|
||||
{LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2)},
|
||||
// 58 57 56 55 54 53 N/A
|
||||
{LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA},
|
||||
// 67 66 65 64 63 62 61
|
||||
{LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2)},
|
||||
// 76 75 74 73 72 60 59
|
||||
{LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0)},
|
||||
// N/A N/A N/A N/A N/A N/A 68
|
||||
{NA, NA, NA, NA, NA, NA, LA(5, 4)},
|
||||
// N/A N/A N/A N/A 71 70 69
|
||||
{NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0)},
|
||||
};
|
||||
|
||||
|
||||
#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
|
||||
#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
|
||||
#define IS31_TIMEOUT 5000
|
||||
|
||||
static GFXINLINE void init_board(GDisplay *g) {
|
||||
(void) g;
|
||||
static GFXINLINE void init_board(GDisplay* g) {
|
||||
(void)g;
|
||||
/* I2C pins */
|
||||
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
|
||||
palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
|
||||
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
|
||||
palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
|
||||
palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(GPIOB, 16);
|
||||
/* start I2C */
|
||||
@ -77,34 +76,30 @@ static GFXINLINE void init_board(GDisplay *g) {
|
||||
I2CD1.i2c->FLT = 4;
|
||||
}
|
||||
|
||||
static GFXINLINE void post_init_board(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
static GFXINLINE void post_init_board(GDisplay* g) { (void)g; }
|
||||
|
||||
static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) {
|
||||
(void) g;
|
||||
(void)g;
|
||||
return led_mask;
|
||||
}
|
||||
|
||||
static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y)
|
||||
{
|
||||
(void) g;
|
||||
static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y) {
|
||||
(void)g;
|
||||
return led_mapping[y][x];
|
||||
}
|
||||
|
||||
static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) {
|
||||
(void) g;
|
||||
if(!shutdown) {
|
||||
(void)g;
|
||||
if (!shutdown) {
|
||||
palSetPad(GPIOB, 16);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
palClearPad(GPIOB, 16);
|
||||
}
|
||||
}
|
||||
|
||||
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
|
||||
(void) g;
|
||||
i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
|
||||
static GFXINLINE void write_data(GDisplay* g, uint8_t* data, uint16_t length) {
|
||||
(void)g;
|
||||
i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
|
||||
}
|
||||
|
||||
#endif /* _GDISP_LLD_BOARD_H */
|
||||
|
@ -19,15 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#if GFX_USE_GDISP
|
||||
|
||||
#define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK
|
||||
#define GDISP_SCREEN_HEIGHT LED_HEIGHT
|
||||
#define GDISP_SCREEN_WIDTH LED_WIDTH
|
||||
# define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK
|
||||
# define GDISP_SCREEN_HEIGHT LED_HEIGHT
|
||||
# define GDISP_SCREEN_WIDTH LED_WIDTH
|
||||
|
||||
#include "gdisp_lld_config.h"
|
||||
#include "src/gdisp/gdisp_driver.h"
|
||||
|
||||
#include "board_is31fl3731c.h"
|
||||
# include "gdisp_lld_config.h"
|
||||
# include "src/gdisp/gdisp_driver.h"
|
||||
|
||||
# include "board_is31fl3731c.h"
|
||||
|
||||
// Can't include led_tables from here
|
||||
extern const uint8_t CIE1931_CURVE[];
|
||||
@ -36,96 +35,96 @@ extern const uint8_t CIE1931_CURVE[];
|
||||
/* Driver local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifndef GDISP_INITIAL_CONTRAST
|
||||
#define GDISP_INITIAL_CONTRAST 0
|
||||
#endif
|
||||
#ifndef GDISP_INITIAL_BACKLIGHT
|
||||
#define GDISP_INITIAL_BACKLIGHT 0
|
||||
#endif
|
||||
# ifndef GDISP_INITIAL_CONTRAST
|
||||
# define GDISP_INITIAL_CONTRAST 0
|
||||
# endif
|
||||
# ifndef GDISP_INITIAL_BACKLIGHT
|
||||
# define GDISP_INITIAL_BACKLIGHT 0
|
||||
# endif
|
||||
|
||||
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
|
||||
# define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0)
|
||||
|
||||
#define IS31_ADDR_DEFAULT 0x74
|
||||
# define IS31_ADDR_DEFAULT 0x74
|
||||
|
||||
#define IS31_REG_CONFIG 0x00
|
||||
# define IS31_REG_CONFIG 0x00
|
||||
// bits in reg
|
||||
#define IS31_REG_CONFIG_PICTUREMODE 0x00
|
||||
#define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
|
||||
#define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
|
||||
# define IS31_REG_CONFIG_PICTUREMODE 0x00
|
||||
# define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
|
||||
# define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
|
||||
// D2:D0 bits are starting frame for autoplay mode
|
||||
|
||||
#define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
|
||||
# define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
|
||||
|
||||
#define IS31_REG_AUTOPLAYCTRL1 0x02
|
||||
# define IS31_REG_AUTOPLAYCTRL1 0x02
|
||||
// D6:D4 number of loops (000=infty)
|
||||
// D2:D0 number of frames to be used
|
||||
|
||||
#define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
|
||||
# define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
|
||||
|
||||
#define IS31_REG_DISPLAYOPT 0x05
|
||||
#define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
|
||||
#define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
|
||||
# define IS31_REG_DISPLAYOPT 0x05
|
||||
# define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
|
||||
# define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
|
||||
// D2:D0 bits blink period time (*0.27s)
|
||||
|
||||
#define IS31_REG_AUDIOSYNC 0x06
|
||||
#define IS31_REG_AUDIOSYNC_ENABLE 0x1
|
||||
# define IS31_REG_AUDIOSYNC 0x06
|
||||
# define IS31_REG_AUDIOSYNC_ENABLE 0x1
|
||||
|
||||
#define IS31_REG_FRAMESTATE 0x07
|
||||
# define IS31_REG_FRAMESTATE 0x07
|
||||
|
||||
#define IS31_REG_BREATHCTRL1 0x08
|
||||
# define IS31_REG_BREATHCTRL1 0x08
|
||||
// D6:D4 fade out time (26ms*2^i)
|
||||
// D2:D0 fade in time (26ms*2^i)
|
||||
|
||||
#define IS31_REG_BREATHCTRL2 0x09
|
||||
#define IS31_REG_BREATHCTRL2_ENABLE 0x10
|
||||
# define IS31_REG_BREATHCTRL2 0x09
|
||||
# define IS31_REG_BREATHCTRL2_ENABLE 0x10
|
||||
// D2:D0 extinguish time (3.5ms*2^i)
|
||||
|
||||
#define IS31_REG_SHUTDOWN 0x0A
|
||||
#define IS31_REG_SHUTDOWN_OFF 0x0
|
||||
#define IS31_REG_SHUTDOWN_ON 0x1
|
||||
# define IS31_REG_SHUTDOWN 0x0A
|
||||
# define IS31_REG_SHUTDOWN_OFF 0x0
|
||||
# define IS31_REG_SHUTDOWN_ON 0x1
|
||||
|
||||
#define IS31_REG_AGCCTRL 0x0B
|
||||
#define IS31_REG_ADCRATE 0x0C
|
||||
# define IS31_REG_AGCCTRL 0x0B
|
||||
# define IS31_REG_ADCRATE 0x0C
|
||||
|
||||
#define IS31_COMMANDREGISTER 0xFD
|
||||
#define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
#define IS31_FUNCTIONREG_SIZE 0xD
|
||||
# define IS31_COMMANDREGISTER 0xFD
|
||||
# define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
# define IS31_FUNCTIONREG_SIZE 0xD
|
||||
|
||||
#define IS31_FRAME_SIZE 0xB4
|
||||
# define IS31_FRAME_SIZE 0xB4
|
||||
|
||||
#define IS31_PWM_REG 0x24
|
||||
#define IS31_PWM_SIZE 0x90
|
||||
# define IS31_PWM_REG 0x24
|
||||
# define IS31_PWM_SIZE 0x90
|
||||
|
||||
#define IS31_LED_MASK_SIZE 0x12
|
||||
# define IS31_LED_MASK_SIZE 0x12
|
||||
|
||||
#define IS31
|
||||
# define IS31
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
uint8_t write_buffer_offset;
|
||||
uint8_t write_buffer[IS31_FRAME_SIZE];
|
||||
uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH];
|
||||
uint8_t page;
|
||||
}__attribute__((__packed__)) PrivData;
|
||||
} __attribute__((__packed__)) PrivData;
|
||||
|
||||
// Some common routines and macros
|
||||
#define PRIV(g) ((PrivData*)g->priv)
|
||||
# define PRIV(g) ((PrivData *)g->priv)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
static GFXINLINE void write_page(GDisplay* g, uint8_t page) {
|
||||
static GFXINLINE void write_page(GDisplay *g, uint8_t page) {
|
||||
uint8_t tx[2] __attribute__((aligned(2)));
|
||||
tx[0] = IS31_COMMANDREGISTER;
|
||||
tx[1] = page;
|
||||
write_data(g, tx, 2);
|
||||
}
|
||||
|
||||
static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uint8_t data) {
|
||||
static GFXINLINE void write_register(GDisplay *g, uint8_t page, uint8_t reg, uint8_t data) {
|
||||
uint8_t tx[2] __attribute__((aligned(2)));
|
||||
tx[0] = reg;
|
||||
tx[1] = data;
|
||||
@ -136,7 +135,7 @@ static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uin
|
||||
static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) {
|
||||
PRIV(g)->write_buffer_offset = offset;
|
||||
write_page(g, page);
|
||||
write_data(g, (uint8_t*)PRIV(g), length + 1);
|
||||
write_data(g, (uint8_t *)PRIV(g), length + 1);
|
||||
}
|
||||
|
||||
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||
@ -160,10 +159,9 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||
write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
|
||||
gfxSleepMilliseconds(10);
|
||||
|
||||
|
||||
// zero all LED registers on all 8 pages, and enable the mask
|
||||
__builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE);
|
||||
for(uint8_t i=0; i<8; i++) {
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
write_ram(g, i, 0, IS31_FRAME_SIZE);
|
||||
gfxSleepMilliseconds(1);
|
||||
}
|
||||
@ -176,133 +174,129 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||
post_init_board(g);
|
||||
|
||||
/* Initialise the GDISP structure */
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Orientation = GDISP_ROTATE_0;
|
||||
g->g.Powermode = powerOff;
|
||||
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
|
||||
g->g.Contrast = GDISP_INITIAL_CONTRAST;
|
||||
g->g.Powermode = powerOff;
|
||||
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
|
||||
g->g.Contrast = GDISP_INITIAL_CONTRAST;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if GDISP_HARDWARE_FLUSH
|
||||
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
||||
// Don't flush if we don't need it.
|
||||
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
|
||||
return;
|
||||
# if GDISP_HARDWARE_FLUSH
|
||||
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
||||
// Don't flush if we don't need it.
|
||||
if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return;
|
||||
|
||||
PRIV(g)->page++;
|
||||
PRIV(g)->page %= 2;
|
||||
// TODO: some smarter algorithm for this
|
||||
// We should run only one physical page at a time
|
||||
// This way we don't need to send so much data, and
|
||||
// we could use slightly less memory
|
||||
uint8_t* src = PRIV(g)->frame_buffer;
|
||||
for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
|
||||
for (int x=0;x<GDISP_SCREEN_WIDTH;x++) {
|
||||
uint8_t val = (uint16_t)*src * g->g.Backlight / 100;
|
||||
PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val];
|
||||
++src;
|
||||
}
|
||||
PRIV(g)->page++;
|
||||
PRIV(g)->page %= 2;
|
||||
// TODO: some smarter algorithm for this
|
||||
// We should run only one physical page at a time
|
||||
// This way we don't need to send so much data, and
|
||||
// we could use slightly less memory
|
||||
uint8_t *src = PRIV(g)->frame_buffer;
|
||||
for (int y = 0; y < GDISP_SCREEN_HEIGHT; y++) {
|
||||
for (int x = 0; x < GDISP_SCREEN_WIDTH; x++) {
|
||||
uint8_t val = (uint16_t)*src * g->g.Backlight / 100;
|
||||
PRIV(g)->write_buffer[get_led_address(g, x, y)] = CIE1931_CURVE[val];
|
||||
++src;
|
||||
}
|
||||
write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
|
||||
gfxSleepMilliseconds(1);
|
||||
write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
|
||||
|
||||
g->flags &= ~GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
#endif
|
||||
write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
|
||||
gfxSleepMilliseconds(1);
|
||||
write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
|
||||
|
||||
#if GDISP_HARDWARE_DRAWPIXEL
|
||||
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
|
||||
coord_t x, y;
|
||||
g->flags &= ~GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
# endif
|
||||
|
||||
switch(g->g.Orientation) {
|
||||
# if GDISP_HARDWARE_DRAWPIXEL
|
||||
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
|
||||
coord_t x, y;
|
||||
|
||||
switch (g->g.Orientation) {
|
||||
default:
|
||||
case GDISP_ROTATE_0:
|
||||
x = g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_180:
|
||||
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
|
||||
x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
}
|
||||
PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
|
||||
g->flags |= GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
#endif
|
||||
PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
|
||||
g->flags |= GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
# endif
|
||||
|
||||
#if GDISP_HARDWARE_PIXELREAD
|
||||
LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
|
||||
coord_t x, y;
|
||||
# if GDISP_HARDWARE_PIXELREAD
|
||||
LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
|
||||
coord_t x, y;
|
||||
|
||||
switch(g->g.Orientation) {
|
||||
switch (g->g.Orientation) {
|
||||
default:
|
||||
case GDISP_ROTATE_0:
|
||||
x = g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_180:
|
||||
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
|
||||
x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
}
|
||||
return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
|
||||
}
|
||||
#endif
|
||||
return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
|
||||
}
|
||||
# endif
|
||||
|
||||
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
||||
LLDSPEC void gdisp_lld_control(GDisplay *g) {
|
||||
switch(g->p.x) {
|
||||
# if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
||||
LLDSPEC void gdisp_lld_control(GDisplay *g) {
|
||||
switch (g->p.x) {
|
||||
case GDISP_CONTROL_POWER:
|
||||
if (g->g.Powermode == (powermode_t)g->p.ptr)
|
||||
return;
|
||||
switch((powermode_t)g->p.ptr) {
|
||||
case powerOff:
|
||||
case powerSleep:
|
||||
case powerDeepSleep:
|
||||
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
|
||||
break;
|
||||
case powerOn:
|
||||
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
if (g->g.Powermode == (powermode_t)g->p.ptr) return;
|
||||
switch ((powermode_t)g->p.ptr) {
|
||||
case powerOff:
|
||||
case powerSleep:
|
||||
case powerDeepSleep:
|
||||
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
|
||||
break;
|
||||
case powerOn:
|
||||
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
g->g.Powermode = (powermode_t)g->p.ptr;
|
||||
return;
|
||||
|
||||
case GDISP_CONTROL_ORIENTATION:
|
||||
if (g->g.Orientation == (orientation_t)g->p.ptr)
|
||||
return;
|
||||
switch((orientation_t)g->p.ptr) {
|
||||
/* Rotation is handled by the drawing routines */
|
||||
case GDISP_ROTATE_0:
|
||||
case GDISP_ROTATE_180:
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
case GDISP_ROTATE_270:
|
||||
g->g.Height = GDISP_SCREEN_WIDTH;
|
||||
g->g.Width = GDISP_SCREEN_HEIGHT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
if (g->g.Orientation == (orientation_t)g->p.ptr) return;
|
||||
switch ((orientation_t)g->p.ptr) {
|
||||
/* Rotation is handled by the drawing routines */
|
||||
case GDISP_ROTATE_0:
|
||||
case GDISP_ROTATE_180:
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
case GDISP_ROTATE_270:
|
||||
g->g.Height = GDISP_SCREEN_WIDTH;
|
||||
g->g.Width = GDISP_SCREEN_HEIGHT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
g->g.Orientation = (orientation_t)g->p.ptr;
|
||||
return;
|
||||
|
||||
case GDISP_CONTROL_BACKLIGHT:
|
||||
if (g->g.Backlight == (unsigned)g->p.ptr)
|
||||
return;
|
||||
unsigned val = (unsigned)g->p.ptr;
|
||||
if (g->g.Backlight == (unsigned)g->p.ptr) return;
|
||||
unsigned val = (unsigned)g->p.ptr;
|
||||
g->g.Backlight = val > 100 ? 100 : val;
|
||||
g->flags |= GDISP_FLG_NEEDFLUSH;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // GDISP_NEED_CONTROL
|
||||
}
|
||||
# endif // GDISP_NEED_CONTROL
|
||||
|
||||
#endif // GFX_USE_GDISP
|
||||
#endif // GFX_USE_GDISP
|
||||
|
@ -24,13 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* Driver hardware support. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
|
||||
#define GDISP_HARDWARE_DRAWPIXEL TRUE
|
||||
#define GDISP_HARDWARE_PIXELREAD TRUE
|
||||
#define GDISP_HARDWARE_CONTROL TRUE
|
||||
# define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
|
||||
# define GDISP_HARDWARE_DRAWPIXEL TRUE
|
||||
# define GDISP_HARDWARE_PIXELREAD TRUE
|
||||
# define GDISP_HARDWARE_CONTROL TRUE
|
||||
|
||||
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256
|
||||
# define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256
|
||||
|
||||
#endif /* GFX_USE_GDISP */
|
||||
#endif /* GFX_USE_GDISP */
|
||||
|
||||
#endif /* _GDISP_LLD_CONFIG_H */
|
||||
#endif /* _GDISP_LLD_CONFIG_H */
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef _GDISP_LLD_BOARD_H
|
||||
#define _GDISP_LLD_BOARD_H
|
||||
|
||||
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6
|
||||
#define ST7565_ADC ST7565_ADC_NORMAL
|
||||
#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
|
||||
#define ST7565_PAGE_ORDER 0,1,2,3
|
||||
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6
|
||||
#define ST7565_ADC ST7565_ADC_NORMAL
|
||||
#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
|
||||
#define ST7565_PAGE_ORDER 0, 1, 2, 3
|
||||
/*
|
||||
* Custom page order for several LCD boards, e.g. HEM12864-99
|
||||
* #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3
|
||||
@ -25,11 +25,9 @@
|
||||
#define ST7565_SLCK_PIN 5
|
||||
#define ST7565_SS_PIN 4
|
||||
|
||||
#define palSetPadModeRaw(portname, bits) \
|
||||
ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
|
||||
#define palSetPadModeRaw(portname, bits) ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
|
||||
|
||||
#define palSetPadModeNamed(portname, portmode) \
|
||||
palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
|
||||
#define palSetPadModeNamed(portname, portmode) palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
|
||||
|
||||
#define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2)
|
||||
// DSPI Clock and Transfer Attributes
|
||||
@ -37,38 +35,37 @@
|
||||
// MSB First
|
||||
// CLK Low by default
|
||||
static const SPIConfig spi1config = {
|
||||
// Operation complete callback or @p NULL.
|
||||
.end_cb = NULL,
|
||||
//The chip select line port - when not using pcs.
|
||||
.ssport = ST7565_GPIOPORT,
|
||||
// brief The chip select line pad number - when not using pcs.
|
||||
.sspad=ST7565_SS_PIN,
|
||||
// SPI initialization data.
|
||||
.tar0 =
|
||||
SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
|
||||
| SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
|
||||
| SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns
|
||||
| SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns
|
||||
| SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2
|
||||
| SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
|
||||
// Operation complete callback or @p NULL.
|
||||
.end_cb = NULL,
|
||||
// The chip select line port - when not using pcs.
|
||||
.ssport = ST7565_GPIOPORT,
|
||||
// brief The chip select line pad number - when not using pcs.
|
||||
.sspad = ST7565_SS_PIN,
|
||||
// SPI initialization data.
|
||||
.tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
|
||||
| SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
|
||||
| SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns
|
||||
| SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns
|
||||
| SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2
|
||||
| SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
|
||||
};
|
||||
|
||||
static GFXINLINE void acquire_bus(GDisplay *g) {
|
||||
(void) g;
|
||||
(void)g;
|
||||
// Only the LCD is using the SPI bus, so no need to acquire
|
||||
// spiAcquireBus(&SPID1);
|
||||
spiSelect(&SPID1);
|
||||
}
|
||||
|
||||
static GFXINLINE void release_bus(GDisplay *g) {
|
||||
(void) g;
|
||||
(void)g;
|
||||
// Only the LCD is using the SPI bus, so no need to release
|
||||
//spiReleaseBus(&SPID1);
|
||||
// spiReleaseBus(&SPID1);
|
||||
spiUnselect(&SPID1);
|
||||
}
|
||||
|
||||
static GFXINLINE void init_board(GDisplay *g) {
|
||||
(void) g;
|
||||
(void)g;
|
||||
palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
|
||||
palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
@ -82,31 +79,23 @@ static GFXINLINE void init_board(GDisplay *g) {
|
||||
release_bus(g);
|
||||
}
|
||||
|
||||
static GFXINLINE void post_init_board(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
static GFXINLINE void post_init_board(GDisplay *g) { (void)g; }
|
||||
|
||||
static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
|
||||
(void) g;
|
||||
(void)g;
|
||||
if (state) {
|
||||
palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
|
||||
}
|
||||
}
|
||||
|
||||
static GFXINLINE void enter_data_mode(GDisplay *g) {
|
||||
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
|
||||
}
|
||||
static GFXINLINE void enter_data_mode(GDisplay *g) { palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); }
|
||||
|
||||
static GFXINLINE void enter_cmd_mode(GDisplay *g) {
|
||||
palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN);
|
||||
}
|
||||
static GFXINLINE void enter_cmd_mode(GDisplay *g) { palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN); }
|
||||
|
||||
|
||||
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
|
||||
(void) g;
|
||||
static GFXINLINE void write_data(GDisplay *g, uint8_t *data, uint16_t length) {
|
||||
(void)g;
|
||||
spiSend(&SPID1, length, data);
|
||||
}
|
||||
|
||||
|
@ -9,82 +9,89 @@
|
||||
|
||||
#if GFX_USE_GDISP
|
||||
|
||||
#define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK
|
||||
#include "gdisp_lld_config.h"
|
||||
#include "src/gdisp/gdisp_driver.h"
|
||||
# define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK
|
||||
# include "gdisp_lld_config.h"
|
||||
# include "src/gdisp/gdisp_driver.h"
|
||||
|
||||
#include "board_st7565.h"
|
||||
# include "board_st7565.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifndef GDISP_SCREEN_HEIGHT
|
||||
#define GDISP_SCREEN_HEIGHT LCD_HEIGHT
|
||||
#endif
|
||||
#ifndef GDISP_SCREEN_WIDTH
|
||||
#define GDISP_SCREEN_WIDTH LCD_WIDTH
|
||||
#endif
|
||||
#ifndef GDISP_INITIAL_CONTRAST
|
||||
#define GDISP_INITIAL_CONTRAST 35
|
||||
#endif
|
||||
#ifndef GDISP_INITIAL_BACKLIGHT
|
||||
#define GDISP_INITIAL_BACKLIGHT 100
|
||||
#endif
|
||||
# ifndef GDISP_SCREEN_HEIGHT
|
||||
# define GDISP_SCREEN_HEIGHT LCD_HEIGHT
|
||||
# endif
|
||||
# ifndef GDISP_SCREEN_WIDTH
|
||||
# define GDISP_SCREEN_WIDTH LCD_WIDTH
|
||||
# endif
|
||||
# ifndef GDISP_INITIAL_CONTRAST
|
||||
# define GDISP_INITIAL_CONTRAST 35
|
||||
# endif
|
||||
# ifndef GDISP_INITIAL_BACKLIGHT
|
||||
# define GDISP_INITIAL_BACKLIGHT 100
|
||||
# endif
|
||||
|
||||
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
|
||||
# define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0)
|
||||
|
||||
#include "st7565.h"
|
||||
# include "st7565.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver config defaults for backward compatibility. */
|
||||
/*===========================================================================*/
|
||||
#ifndef ST7565_LCD_BIAS
|
||||
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
|
||||
#endif
|
||||
#ifndef ST7565_ADC
|
||||
#define ST7565_ADC ST7565_ADC_NORMAL
|
||||
#endif
|
||||
#ifndef ST7565_COM_SCAN
|
||||
#define ST7565_COM_SCAN ST7565_COM_SCAN_INC
|
||||
#endif
|
||||
#ifndef ST7565_PAGE_ORDER
|
||||
#define ST7565_PAGE_ORDER 0,1,2,3
|
||||
#endif
|
||||
# ifndef ST7565_LCD_BIAS
|
||||
# define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
|
||||
# endif
|
||||
# ifndef ST7565_ADC
|
||||
# define ST7565_ADC ST7565_ADC_NORMAL
|
||||
# endif
|
||||
# ifndef ST7565_COM_SCAN
|
||||
# define ST7565_COM_SCAN ST7565_COM_SCAN_INC
|
||||
# endif
|
||||
# ifndef ST7565_PAGE_ORDER
|
||||
# define ST7565_PAGE_ORDER 0, 1, 2, 3
|
||||
# endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct{
|
||||
bool_t buffer2;
|
||||
typedef struct {
|
||||
bool_t buffer2;
|
||||
uint8_t data_pos;
|
||||
uint8_t data[16];
|
||||
uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8];
|
||||
}PrivData;
|
||||
} PrivData;
|
||||
|
||||
// Some common routines and macros
|
||||
#define PRIV(g) ((PrivData*)g->priv)
|
||||
#define RAM(g) (PRIV(g)->ram)
|
||||
# define PRIV(g) ((PrivData *)g->priv)
|
||||
# define RAM(g) (PRIV(g)->ram)
|
||||
|
||||
static GFXINLINE void write_cmd(GDisplay* g, uint8_t cmd) {
|
||||
PRIV(g)->data[PRIV(g)->data_pos++] = cmd;
|
||||
}
|
||||
static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) { PRIV(g)->data[PRIV(g)->data_pos++] = cmd; }
|
||||
|
||||
static GFXINLINE void flush_cmd(GDisplay* g) {
|
||||
static GFXINLINE void flush_cmd(GDisplay *g) {
|
||||
write_data(g, PRIV(g)->data, PRIV(g)->data_pos);
|
||||
PRIV(g)->data_pos = 0;
|
||||
}
|
||||
|
||||
#define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); }
|
||||
#define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); }
|
||||
# define write_cmd2(g, cmd1, cmd2) \
|
||||
{ \
|
||||
write_cmd(g, cmd1); \
|
||||
write_cmd(g, cmd2); \
|
||||
}
|
||||
# define write_cmd3(g, cmd1, cmd2, cmd3) \
|
||||
{ \
|
||||
write_cmd(g, cmd1); \
|
||||
write_cmd(g, cmd2); \
|
||||
write_cmd(g, cmd3); \
|
||||
}
|
||||
|
||||
// Some common routines and macros
|
||||
#define delay(us) gfxSleepMicroseconds(us)
|
||||
#define delay_ms(ms) gfxSleepMilliseconds(ms)
|
||||
# define delay(us) gfxSleepMicroseconds(us)
|
||||
# define delay_ms(ms) gfxSleepMilliseconds(ms)
|
||||
|
||||
#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH)
|
||||
#define xybit(y) (1<<((y)&7))
|
||||
# define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH)
|
||||
# define xybit(y) (1 << ((y)&7))
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
@ -99,8 +106,8 @@ static GFXINLINE void flush_cmd(GDisplay* g) {
|
||||
|
||||
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||
// The private area is the display surface.
|
||||
g->priv = gfxAlloc(sizeof(PrivData));
|
||||
PRIV(g)->buffer2 = false;
|
||||
g->priv = gfxAlloc(sizeof(PrivData));
|
||||
PRIV(g)->buffer2 = false;
|
||||
PRIV(g)->data_pos = 0;
|
||||
|
||||
// Initialise the board interface
|
||||
@ -139,22 +146,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||
release_bus(g);
|
||||
|
||||
/* Initialise the GDISP structure */
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Orientation = GDISP_ROTATE_0;
|
||||
g->g.Powermode = powerOff;
|
||||
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
|
||||
g->g.Contrast = GDISP_INITIAL_CONTRAST;
|
||||
g->g.Powermode = powerOff;
|
||||
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
|
||||
g->g.Contrast = GDISP_INITIAL_CONTRAST;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if GDISP_HARDWARE_FLUSH
|
||||
# if GDISP_HARDWARE_FLUSH
|
||||
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
||||
unsigned p;
|
||||
unsigned p;
|
||||
|
||||
// Don't flush if we don't need it.
|
||||
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
|
||||
return;
|
||||
if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return;
|
||||
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
@ -166,7 +172,7 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
||||
write_cmd(g, ST7565_RMW);
|
||||
flush_cmd(g);
|
||||
enter_data_mode(g);
|
||||
write_data(g, RAM(g) + (p*GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
|
||||
write_data(g, RAM(g) + (p * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
|
||||
enter_cmd_mode(g);
|
||||
}
|
||||
unsigned line = (PRIV(g)->buffer2 ? 32 : 0);
|
||||
@ -177,30 +183,30 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
|
||||
|
||||
g->flags &= ~GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#if GDISP_HARDWARE_DRAWPIXEL
|
||||
# if GDISP_HARDWARE_DRAWPIXEL
|
||||
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
|
||||
coord_t x, y;
|
||||
coord_t x, y;
|
||||
|
||||
switch(g->g.Orientation) {
|
||||
default:
|
||||
case GDISP_ROTATE_0:
|
||||
x = g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
x = g->p.y;
|
||||
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
|
||||
break;
|
||||
case GDISP_ROTATE_180:
|
||||
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
|
||||
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_270:
|
||||
x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
|
||||
y = g->p.x;
|
||||
break;
|
||||
switch (g->g.Orientation) {
|
||||
default:
|
||||
case GDISP_ROTATE_0:
|
||||
x = g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
x = g->p.y;
|
||||
y = GDISP_SCREEN_HEIGHT - 1 - g->p.x;
|
||||
break;
|
||||
case GDISP_ROTATE_180:
|
||||
x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
|
||||
y = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_270:
|
||||
x = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
|
||||
y = g->p.x;
|
||||
break;
|
||||
}
|
||||
if (gdispColor2Native(g->p.color) != Black)
|
||||
RAM(g)[xyaddr(x, y)] |= xybit(y);
|
||||
@ -208,53 +214,52 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
|
||||
RAM(g)[xyaddr(x, y)] &= ~xybit(y);
|
||||
g->flags |= GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#if GDISP_HARDWARE_PIXELREAD
|
||||
# if GDISP_HARDWARE_PIXELREAD
|
||||
LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
|
||||
coord_t x, y;
|
||||
coord_t x, y;
|
||||
|
||||
switch(g->g.Orientation) {
|
||||
default:
|
||||
case GDISP_ROTATE_0:
|
||||
x = g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
x = g->p.y;
|
||||
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
|
||||
break;
|
||||
case GDISP_ROTATE_180:
|
||||
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
|
||||
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_270:
|
||||
x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
|
||||
y = g->p.x;
|
||||
break;
|
||||
switch (g->g.Orientation) {
|
||||
default:
|
||||
case GDISP_ROTATE_0:
|
||||
x = g->p.x;
|
||||
y = g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
x = g->p.y;
|
||||
y = GDISP_SCREEN_HEIGHT - 1 - g->p.x;
|
||||
break;
|
||||
case GDISP_ROTATE_180:
|
||||
x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
|
||||
y = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
|
||||
break;
|
||||
case GDISP_ROTATE_270:
|
||||
x = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
|
||||
y = g->p.x;
|
||||
break;
|
||||
}
|
||||
return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black;
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
|
||||
uint8_t* buffer = (uint8_t*)g->p.ptr;
|
||||
int linelength = g->p.cx;
|
||||
uint8_t *buffer = (uint8_t *)g->p.ptr;
|
||||
int linelength = g->p.cx;
|
||||
for (int i = 0; i < g->p.cy; i++) {
|
||||
unsigned dstx = g->p.x;
|
||||
unsigned dsty = g->p.y + i;
|
||||
unsigned srcx = g->p.x1;
|
||||
unsigned srcy = g->p.y1 + i;
|
||||
unsigned dstx = g->p.x;
|
||||
unsigned dsty = g->p.y + i;
|
||||
unsigned srcx = g->p.x1;
|
||||
unsigned srcy = g->p.y1 + i;
|
||||
unsigned srcbit = srcy * g->p.x2 + srcx;
|
||||
for(int j=0; j < linelength; j++) {
|
||||
uint8_t src = buffer[srcbit / 8];
|
||||
uint8_t bit = 7-(srcbit % 8);
|
||||
uint8_t bitset = (src >> bit) & 1;
|
||||
uint8_t* dst = &(RAM(g)[xyaddr(dstx, dsty)]);
|
||||
for (int j = 0; j < linelength; j++) {
|
||||
uint8_t src = buffer[srcbit / 8];
|
||||
uint8_t bit = 7 - (srcbit % 8);
|
||||
uint8_t bitset = (src >> bit) & 1;
|
||||
uint8_t *dst = &(RAM(g)[xyaddr(dstx, dsty)]);
|
||||
if (bitset) {
|
||||
*dst |= xybit(dsty);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
*dst &= ~xybit(dsty);
|
||||
}
|
||||
dstx++;
|
||||
@ -264,66 +269,64 @@ LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
|
||||
g->flags |= GDISP_FLG_NEEDFLUSH;
|
||||
}
|
||||
|
||||
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
||||
# if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
||||
LLDSPEC void gdisp_lld_control(GDisplay *g) {
|
||||
switch(g->p.x) {
|
||||
case GDISP_CONTROL_POWER:
|
||||
if (g->g.Powermode == (powermode_t)g->p.ptr)
|
||||
switch (g->p.x) {
|
||||
case GDISP_CONTROL_POWER:
|
||||
if (g->g.Powermode == (powermode_t)g->p.ptr) return;
|
||||
switch ((powermode_t)g->p.ptr) {
|
||||
case powerOff:
|
||||
case powerSleep:
|
||||
case powerDeepSleep:
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
write_cmd(g, ST7565_DISPLAY_OFF);
|
||||
flush_cmd(g);
|
||||
release_bus(g);
|
||||
break;
|
||||
case powerOn:
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
write_cmd(g, ST7565_DISPLAY_ON);
|
||||
flush_cmd(g);
|
||||
release_bus(g);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
g->g.Powermode = (powermode_t)g->p.ptr;
|
||||
return;
|
||||
switch((powermode_t)g->p.ptr) {
|
||||
case powerOff:
|
||||
case powerSleep:
|
||||
case powerDeepSleep:
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
write_cmd(g, ST7565_DISPLAY_OFF);
|
||||
flush_cmd(g);
|
||||
release_bus(g);
|
||||
break;
|
||||
case powerOn:
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
write_cmd(g, ST7565_DISPLAY_ON);
|
||||
flush_cmd(g);
|
||||
release_bus(g);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
g->g.Powermode = (powermode_t)g->p.ptr;
|
||||
return;
|
||||
|
||||
case GDISP_CONTROL_ORIENTATION:
|
||||
if (g->g.Orientation == (orientation_t)g->p.ptr)
|
||||
return;
|
||||
switch((orientation_t)g->p.ptr) {
|
||||
/* Rotation is handled by the drawing routines */
|
||||
case GDISP_ROTATE_0:
|
||||
case GDISP_ROTATE_180:
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
case GDISP_ROTATE_270:
|
||||
g->g.Height = GDISP_SCREEN_WIDTH;
|
||||
g->g.Width = GDISP_SCREEN_HEIGHT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
if (g->g.Orientation == (orientation_t)g->p.ptr) return;
|
||||
switch ((orientation_t)g->p.ptr) {
|
||||
/* Rotation is handled by the drawing routines */
|
||||
case GDISP_ROTATE_0:
|
||||
case GDISP_ROTATE_180:
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
break;
|
||||
case GDISP_ROTATE_90:
|
||||
case GDISP_ROTATE_270:
|
||||
g->g.Height = GDISP_SCREEN_WIDTH;
|
||||
g->g.Width = GDISP_SCREEN_HEIGHT;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
g->g.Orientation = (orientation_t)g->p.ptr;
|
||||
return;
|
||||
|
||||
case GDISP_CONTROL_CONTRAST:
|
||||
g->g.Contrast = (unsigned)g->p.ptr & 63;
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
write_cmd2(g, ST7565_CONTRAST, g->g.Contrast);
|
||||
flush_cmd(g);
|
||||
release_bus(g);
|
||||
return;
|
||||
case GDISP_CONTROL_CONTRAST:
|
||||
g->g.Contrast = (unsigned)g->p.ptr & 63;
|
||||
acquire_bus(g);
|
||||
enter_cmd_mode(g);
|
||||
write_cmd2(g, ST7565_CONTRAST, g->g.Contrast);
|
||||
flush_cmd(g);
|
||||
release_bus(g);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // GDISP_NEED_CONTROL
|
||||
# endif // GDISP_NEED_CONTROL
|
||||
|
||||
#endif // GFX_USE_GDISP
|
||||
#endif // GFX_USE_GDISP
|
||||
|
@ -14,14 +14,14 @@
|
||||
/* Driver hardware support. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
|
||||
#define GDISP_HARDWARE_DRAWPIXEL TRUE
|
||||
#define GDISP_HARDWARE_PIXELREAD TRUE
|
||||
#define GDISP_HARDWARE_CONTROL TRUE
|
||||
#define GDISP_HARDWARE_BITFILLS TRUE
|
||||
# define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
|
||||
# define GDISP_HARDWARE_DRAWPIXEL TRUE
|
||||
# define GDISP_HARDWARE_PIXELREAD TRUE
|
||||
# define GDISP_HARDWARE_CONTROL TRUE
|
||||
# define GDISP_HARDWARE_BITFILLS TRUE
|
||||
|
||||
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
|
||||
# define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
|
||||
|
||||
#endif /* GFX_USE_GDISP */
|
||||
#endif /* GFX_USE_GDISP */
|
||||
|
||||
#endif /* _GDISP_LLD_CONFIG_H */
|
||||
#endif /* _GDISP_LLD_CONFIG_H */
|
||||
|
@ -8,32 +8,32 @@
|
||||
#ifndef _ST7565_H
|
||||
#define _ST7565_H
|
||||
|
||||
#define ST7565_CONTRAST 0x81
|
||||
#define ST7565_ALLON_NORMAL 0xA4
|
||||
#define ST7565_ALLON 0xA5
|
||||
#define ST7565_POSITIVE_DISPLAY 0xA6
|
||||
#define ST7565_INVERT_DISPLAY 0xA7
|
||||
#define ST7565_DISPLAY_OFF 0xAE
|
||||
#define ST7565_DISPLAY_ON 0xAF
|
||||
#define ST7565_CONTRAST 0x81
|
||||
#define ST7565_ALLON_NORMAL 0xA4
|
||||
#define ST7565_ALLON 0xA5
|
||||
#define ST7565_POSITIVE_DISPLAY 0xA6
|
||||
#define ST7565_INVERT_DISPLAY 0xA7
|
||||
#define ST7565_DISPLAY_OFF 0xAE
|
||||
#define ST7565_DISPLAY_ON 0xAF
|
||||
|
||||
#define ST7565_LCD_BIAS_7 0xA3
|
||||
#define ST7565_LCD_BIAS_9 0xA2
|
||||
#define ST7565_LCD_BIAS_7 0xA3
|
||||
#define ST7565_LCD_BIAS_9 0xA2
|
||||
|
||||
#define ST7565_ADC_NORMAL 0xA0
|
||||
#define ST7565_ADC_REVERSE 0xA1
|
||||
#define ST7565_ADC_NORMAL 0xA0
|
||||
#define ST7565_ADC_REVERSE 0xA1
|
||||
|
||||
#define ST7565_COM_SCAN_INC 0xC0
|
||||
#define ST7565_COM_SCAN_DEC 0xC8
|
||||
#define ST7565_COM_SCAN_INC 0xC0
|
||||
#define ST7565_COM_SCAN_DEC 0xC8
|
||||
|
||||
#define ST7565_START_LINE 0x40
|
||||
#define ST7565_PAGE 0xB0
|
||||
#define ST7565_COLUMN_MSB 0x10
|
||||
#define ST7565_COLUMN_LSB 0x00
|
||||
#define ST7565_RMW 0xE0
|
||||
#define ST7565_START_LINE 0x40
|
||||
#define ST7565_PAGE 0xB0
|
||||
#define ST7565_COLUMN_MSB 0x10
|
||||
#define ST7565_COLUMN_LSB 0x00
|
||||
#define ST7565_RMW 0xE0
|
||||
|
||||
#define ST7565_RESISTOR_RATIO 0x20
|
||||
#define ST7565_POWER_CONTROL 0x28
|
||||
#define ST7565_RESISTOR_RATIO 0x20
|
||||
#define ST7565_POWER_CONTROL 0x28
|
||||
|
||||
#define ST7565_RESET 0xE2
|
||||
#define ST7565_RESET 0xE2
|
||||
|
||||
#endif /* _ST7565_H */
|
||||
|
1
keyboards/2key2crawl/2key2crawl.c
Normal file
1
keyboards/2key2crawl/2key2crawl.c
Normal file
@ -0,0 +1 @@
|
||||
#include "2key2crawl.h"
|
12
keyboards/2key2crawl/2key2crawl.h
Normal file
12
keyboards/2key2crawl/2key2crawl.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#define LAYOUT( \
|
||||
K00, K01, K02, K03, K15, \
|
||||
K10, K11, K12, K13, K14, K16 \
|
||||
) { \
|
||||
{ K00, K01, K02, K03, KC_NO, KC_NO, KC_NO }, \
|
||||
{ K10, K11, K12, K13, K14, K15, K16 }, \
|
||||
}
|
||||
|
44
keyboards/2key2crawl/config.h
Normal file
44
keyboards/2key2crawl/config.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6090
|
||||
#define DEVICE_VER 0x0002
|
||||
#define MANUFACTURER WoodKeys.click
|
||||
#define PRODUCT 2Key2Crawl
|
||||
#define DESCRIPTION ATX Keycrawl 2018
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 2
|
||||
#define MATRIX_COLS 7
|
||||
|
||||
/* key matrix pins */
|
||||
#define MATRIX_ROW_PINS { C4, C5 }
|
||||
#define MATRIX_COL_PINS { B3, B4, B5, B6, B7, C7, B2 }
|
||||
#define UNUSED_PINS
|
||||
|
||||
|
||||
#define ENCODERS_PAD_A { D0 }
|
||||
#define ENCODERS_PAD_B { D1 }
|
||||
#define ENCODER_RESOLUTION 1
|
||||
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
|
||||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
#define RGB_DI_PIN C6
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 3
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user