Skip to content

Commit 0d313a6

Browse files
committed
stable update
1 parent e79c70a commit 0d313a6

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ The operating system for USB connectable Mokugyo device.
2525
- No need to buy Adafruit's LED because a bit expensive. Recommend NeoPixel compatible LED, like [フルカラーシリアルLEDモジュール \- SWITCH\-SCIENCE](https://www.switch-science.com/catalog/1398/), [NeoPixelフルカラーLEDテープ・5V版各種 – Shigezone Online](https://www.shigezone.com/?product=neopixel_ledtape5v), etc.
2626
- Only 5 pieces needed.
2727
- LED strip type is BEST, will helps making it simply.
28-
- Microphone (optional): [SparkFun Electret Microphone Breakout \- BOB\-12758 \- SparkFun Electronics](https://www.sparkfun.com/products/12758)
28+
- Microphone ~~(optional)~~: [SparkFun Electret Microphone Breakout \- BOB\-12758 \- SparkFun Electronics](https://www.sparkfun.com/products/12758)
29+
- Required from v0.2.
2930

3031
![](./img/1.png)
3132

@@ -103,8 +104,11 @@ Show the repositories here but all of them can be installed by arduino IDE built
103104

104105
- FreeRTOS
105106
[feilipu/Arduino\_FreeRTOS\_Library: A FreeRTOS Library for all Arduino AVR Devices \(Uno, Leonardo, Mega, etc\)](https://github.com/feilipu/Arduino_FreeRTOS_Library)
106-
- NeoPixelBus by Makuna
107-
[Makuna/NeoPixelBus: An Arduino NeoPixel support library supporting a large variety of individually addressable LEDs\. Please refer to the Wiki for more details\. Please use the gitter channel to ask questions as the GitHub Issues feature is used for bug tracking\.](https://github.com/Makuna/NeoPixelBus)
107+
- **Note: MUST BE USE VERSION OF 10.4.4-2 OR EARLIER!**
108+
- ~~NeoPixelBus by Makuna~~ (mokugyOS v0.1 only)
109+
~~[Makuna/NeoPixelBus: An Arduino NeoPixel support library supporting a large variety of individually addressable LEDs\. Please refer to the Wiki for more details\. Please use the gitter channel to ask questions as the GitHub Issues feature is used for bug tracking\.](https://github.com/Makuna/NeoPixelBus)~~
110+
- Adafruit NeoPixel Library (mokugyOS v0.2~)
111+
[adafruit/Adafruit\_NeoPixel: Arduino library for controlling single\-wire LED pixels \(NeoPixel, WS2812, etc\.\)](https://github.com/adafruit/Adafruit_NeoPixel)
108112
- MIDIUSB
109113
[arduino\-libraries/MIDIUSB: A MIDI library over USB, based on PluggableUSB](https://github.com/arduino-libraries/MIDIUSB)
110114
- Adafruit MMA8451 Library

TaskApplication.ino

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
* モードによって挙動が変わります
44
*/
55

6-
#define SHOT_THRESHOLD_ON 3.0
7-
#define SHOT_THRESHOLD_OFF 1.0
8-
#define DIRECTION_THRESHOLD_ON 4.0
9-
#define DIRECTION_THRESHOLD_OFF 2.0
6+
#define SHOT_THRESHOLD_ON 3.0f
7+
#define SHOT_THRESHOLD_OFF 0.5f
8+
#define SHOT_GUARD_MILLISEC 150UL
9+
#define DIRECTION_THRESHOLD_ON 4.0f
10+
#define DIRECTION_THRESHOLD_OFF 2.0f
1011
#define MICLEVEL_DIFF_THRESHOLD 100
1112

1213

@@ -38,7 +39,12 @@ void TaskApplication(void *pvParameters) {
3839
// 叩かれた瞬間の状態
3940
// 今回と前回の差分値がいずれも±SHOT_THRESHOLD_ONを超えるとOK
4041
// かつマイク差分レベルがMICLEVEL_DIFF_THRESHOLDを超えること
41-
if (!hit.previous && mic.diff >= MICLEVEL_DIFF_THRESHOLD && diff.current >= SHOT_THRESHOLD_ON) {
42+
if (
43+
!hit.previous &&
44+
mic.diff >= MICLEVEL_DIFF_THRESHOLD &&
45+
diff.current >= SHOT_THRESHOLD_ON &&
46+
millis() >= (lastHitMillis + SHOT_GUARD_MILLISEC)
47+
) {
4248
hit.current = true;
4349
lastHitMillis = millis();
4450
// LEDを点灯させる
@@ -62,7 +68,7 @@ void TaskApplication(void *pvParameters) {
6268
}
6369

6470
// 叩かれフラグを元の状態に戻す
65-
if (hit.previous && abs(diff.previous) < SHOT_THRESHOLD_OFF) {
71+
if (hit.previous && diff.current <= SHOT_THRESHOLD_OFF) {
6672
hit.current = false;
6773
if (mode == MODE_KEYBOARD) Keyboard.release(KEY_RETURN);
6874
if (mode == MODE_MOUSE) Mouse.release(MOUSE_LEFT);

mokugyOS.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void loop() {
7979
acc.current.x = (mma.x_g * STD_GRAVITY * RC_RATIO) + ((1.0 - RC_RATIO) * acc.previous.x);
8080
acc.current.y = (mma.y_g * STD_GRAVITY * RC_RATIO) + ((1.0 - RC_RATIO) * acc.previous.y);
8181
acc.current.z = mma.z_g * STD_GRAVITY;
82-
delay(20);
82+
delay(30);
8383

8484
// マイク値(平均と差分)
8585
mic.previous = mic.current;

0 commit comments

Comments
 (0)