Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832 MMA7660 mbed
Revision 19:caab1538fa62, committed 2018-04-18
- Comitter:
- suzukimitsuru
- Date:
- Wed Apr 18 11:14:40 2018 +0000
- Parent:
- 18:938ec6971d11
- Commit message:
- ?????????????; ????????????
Changed in this revision
--- a/src/commands.cpp Thu Apr 12 11:44:10 2018 +0900
+++ b/src/commands.cpp Wed Apr 18 11:14:40 2018 +0000
@@ -11,7 +11,7 @@
/* コマンド定義リスト */
COMMAND_TRRIGER commandList[] = {
left, &Command_color,
- center, &Command_led3,
+// center, &Command_led3,
up, &Command_sound,
down, &Command_accel,
right, &Command_liner,
--- a/src/main.cpp Thu Apr 12 11:44:10 2018 +0900
+++ b/src/main.cpp Wed Apr 18 11:14:40 2018 +0000
@@ -25,41 +25,54 @@
COMMAND_TRRIGER *previous = NULL;
while(true) {
- // 要求の取得
+ // 中断だったら
COMMAND_TRRIGER *request = NULL;
- for(int index = 0; commandList[index].trigger != nothing; index++) {
- if (joyStick == commandList[index].trigger) {
- if (previous != &commandList[index]) {
- request = &commandList[index];
- previous = request;
- }
- }
- }
-
- // 要求があったら
- if (request != NULL) {
- bool full = ringbufferPut(request);
- if (full) {
- printf("full\n");
- }
- }
-
- // 要求があって実行中のものと異なる場合
- if (request != NULL && request != current) {
-
+ if (joyStick == center) {
+
// コマンドの終了
current->command->finalize();
current = &triggerNull;
+
+ // リングバッファのクリア
+ while(ringbufferGet() != NULL);
+ } else {
+
+ // 要求の検索
+ for(int index = 0; commandList[index].trigger != nothing; index++) {
+ if (joyStick == commandList[index].trigger) {
+ request = &commandList[index];
+ }
+ }
+
+ // 要求があったら
+ if (request != NULL) {
+
+ // 前回と異なる要求の場合
+ if (previous != request) {
+
+ // コマンドの蓄積
+ bool full = ringbufferPut(request);
+ if (full) {
+ printf("full\n");
+ }
+
+ // 前回の設定
+ previous = request;
+ }
+ } else {
+ previous = NULL;
+ }
}
// 何も処理していない場合に
if (current->trigger == nothing) {
// 要求があったら
- if (request != NULL) {
+ COMMAND_TRRIGER* get = ringbufferGet();
+ if (get != NULL) {
// コマンドを開始
- current = request;
+ current = get;
lcd.locate(0,15);
lcd.printf(" ");
lcd.locate(0,15);
--- a/src/sound.cpp Thu Apr 12 11:44:10 2018 +0900
+++ b/src/sound.cpp Wed Apr 18 11:14:40 2018 +0000
@@ -4,7 +4,8 @@
PwmOut spkr(p26);
static void _Initialize(void) {
- spkr=0.0;
+ spkr = 0.0;
+// spkr.period_ms(1);
}
static void _Finalize(void) {