うおーるぼっとをWiiリモコンでコントロールする新しいプログラムです。 以前のものより、Wiiリモコンが早く繋がる様になりました。 It is a program which controls A with the Wii remote. ※ A Bluetooth dongle and a Wii remote control are needed.

Dependencies:   USBHost mbed FATFileSystem mbed-rtos

Committer:
jksoft
Date:
Mon Jun 10 16:01:50 2013 +0000
Revision:
0:fccb789424fc
1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:fccb789424fc 1 /*
jksoft 0:fccb789424fc 2 * Copyright (C) 2009-2012 by Matthias Ringwald
jksoft 0:fccb789424fc 3 *
jksoft 0:fccb789424fc 4 * Redistribution and use in source and binary forms, with or without
jksoft 0:fccb789424fc 5 * modification, are permitted provided that the following conditions
jksoft 0:fccb789424fc 6 * are met:
jksoft 0:fccb789424fc 7 *
jksoft 0:fccb789424fc 8 * 1. Redistributions of source code must retain the above copyright
jksoft 0:fccb789424fc 9 * notice, this list of conditions and the following disclaimer.
jksoft 0:fccb789424fc 10 * 2. Redistributions in binary form must reproduce the above copyright
jksoft 0:fccb789424fc 11 * notice, this list of conditions and the following disclaimer in the
jksoft 0:fccb789424fc 12 * documentation and/or other materials provided with the distribution.
jksoft 0:fccb789424fc 13 * 3. Neither the name of the copyright holders nor the names of
jksoft 0:fccb789424fc 14 * contributors may be used to endorse or promote products derived
jksoft 0:fccb789424fc 15 * from this software without specific prior written permission.
jksoft 0:fccb789424fc 16 * 4. Any redistribution, use, or modification is done solely for
jksoft 0:fccb789424fc 17 * personal benefit and not for any commercial purpose or for
jksoft 0:fccb789424fc 18 * monetary gain.
jksoft 0:fccb789424fc 19 *
jksoft 0:fccb789424fc 20 * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
jksoft 0:fccb789424fc 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
jksoft 0:fccb789424fc 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
jksoft 0:fccb789424fc 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
jksoft 0:fccb789424fc 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
jksoft 0:fccb789424fc 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
jksoft 0:fccb789424fc 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
jksoft 0:fccb789424fc 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
jksoft 0:fccb789424fc 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jksoft 0:fccb789424fc 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
jksoft 0:fccb789424fc 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
jksoft 0:fccb789424fc 31 * SUCH DAMAGE.
jksoft 0:fccb789424fc 32 *
jksoft 0:fccb789424fc 33 * Please inquire about commercial licensing options at btstack@ringwald.ch
jksoft 0:fccb789424fc 34 *
jksoft 0:fccb789424fc 35 */
jksoft 0:fccb789424fc 36
jksoft 0:fccb789424fc 37 /*
jksoft 0:fccb789424fc 38 * linked_list.c
jksoft 0:fccb789424fc 39 *
jksoft 0:fccb789424fc 40 * Created by Matthias Ringwald on 7/13/09.
jksoft 0:fccb789424fc 41 */
jksoft 0:fccb789424fc 42
jksoft 0:fccb789424fc 43 #include <btstack/linked_list.h>
jksoft 0:fccb789424fc 44 #include <stdlib.h>
jksoft 0:fccb789424fc 45 /**
jksoft 0:fccb789424fc 46 * tests if list is empty
jksoft 0:fccb789424fc 47 */
jksoft 0:fccb789424fc 48 int linked_list_empty(linked_list_t * list){
jksoft 0:fccb789424fc 49 return *list == (void *) 0;
jksoft 0:fccb789424fc 50 }
jksoft 0:fccb789424fc 51
jksoft 0:fccb789424fc 52 /**
jksoft 0:fccb789424fc 53 * linked_list_get_last_item
jksoft 0:fccb789424fc 54 */
jksoft 0:fccb789424fc 55 linked_item_t * linked_list_get_last_item(linked_list_t * list){ // <-- find the last item in the list
jksoft 0:fccb789424fc 56 linked_item_t *lastItem = NULL;
jksoft 0:fccb789424fc 57 linked_item_t *it;
jksoft 0:fccb789424fc 58 for (it = *list; it ; it = it->next){
jksoft 0:fccb789424fc 59 if (it) {
jksoft 0:fccb789424fc 60 lastItem = it;
jksoft 0:fccb789424fc 61 }
jksoft 0:fccb789424fc 62 }
jksoft 0:fccb789424fc 63 return lastItem;
jksoft 0:fccb789424fc 64 }
jksoft 0:fccb789424fc 65
jksoft 0:fccb789424fc 66
jksoft 0:fccb789424fc 67 /**
jksoft 0:fccb789424fc 68 * linked_list_add
jksoft 0:fccb789424fc 69 */
jksoft 0:fccb789424fc 70 void linked_list_add(linked_list_t * list, linked_item_t *item){ // <-- add item to list
jksoft 0:fccb789424fc 71 // check if already in list
jksoft 0:fccb789424fc 72 linked_item_t *it;
jksoft 0:fccb789424fc 73 for (it = *list; it ; it = it->next){
jksoft 0:fccb789424fc 74 if (it == item) {
jksoft 0:fccb789424fc 75 return;
jksoft 0:fccb789424fc 76 }
jksoft 0:fccb789424fc 77 }
jksoft 0:fccb789424fc 78 // add first
jksoft 0:fccb789424fc 79 item->next = *list;
jksoft 0:fccb789424fc 80 *list = item;
jksoft 0:fccb789424fc 81 }
jksoft 0:fccb789424fc 82
jksoft 0:fccb789424fc 83 void linked_list_add_tail(linked_list_t * list, linked_item_t *item){ // <-- add item to list as last element
jksoft 0:fccb789424fc 84 // check if already in list
jksoft 0:fccb789424fc 85 linked_item_t *it;
jksoft 0:fccb789424fc 86 for (it = (linked_item_t *) list; it->next ; it = it->next){
jksoft 0:fccb789424fc 87 if (it->next == item) {
jksoft 0:fccb789424fc 88 return;
jksoft 0:fccb789424fc 89 }
jksoft 0:fccb789424fc 90 }
jksoft 0:fccb789424fc 91 item->next = (linked_item_t*) 0;
jksoft 0:fccb789424fc 92 it->next = item;
jksoft 0:fccb789424fc 93 }
jksoft 0:fccb789424fc 94
jksoft 0:fccb789424fc 95 /**
jksoft 0:fccb789424fc 96 * Remove data_source from run loop
jksoft 0:fccb789424fc 97 *
jksoft 0:fccb789424fc 98 * @note: assumes that data_source_t.next is first element in data_source
jksoft 0:fccb789424fc 99 */
jksoft 0:fccb789424fc 100 int linked_list_remove(linked_list_t * list, linked_item_t *item){ // <-- remove item from list
jksoft 0:fccb789424fc 101 linked_item_t *it;
jksoft 0:fccb789424fc 102 for (it = (linked_item_t *) list; it ; it = it->next){
jksoft 0:fccb789424fc 103 if (it->next == item){
jksoft 0:fccb789424fc 104 it->next = item->next;
jksoft 0:fccb789424fc 105 return 0;
jksoft 0:fccb789424fc 106 }
jksoft 0:fccb789424fc 107 }
jksoft 0:fccb789424fc 108 return -1;
jksoft 0:fccb789424fc 109 }
jksoft 0:fccb789424fc 110
jksoft 0:fccb789424fc 111 void linked_item_set_user(linked_item_t *item, void *user_data){
jksoft 0:fccb789424fc 112 item->next = (linked_item_t *) 0;
jksoft 0:fccb789424fc 113 item->user_data = user_data;
jksoft 0:fccb789424fc 114 }
jksoft 0:fccb789424fc 115
jksoft 0:fccb789424fc 116 void * linked_item_get_user(linked_item_t *item) {
jksoft 0:fccb789424fc 117 return item->user_data;
jksoft 0:fccb789424fc 118 }
jksoft 0:fccb789424fc 119
jksoft 0:fccb789424fc 120 #if 0
jksoft 0:fccb789424fc 121 #include <stdio.h>
jksoft 0:fccb789424fc 122 void test_linked_list(){
jksoft 0:fccb789424fc 123 linked_list_t testList = 0;
jksoft 0:fccb789424fc 124 linked_item_t itemA;
jksoft 0:fccb789424fc 125 linked_item_t itemB;
jksoft 0:fccb789424fc 126 linked_item_t itemC;
jksoft 0:fccb789424fc 127 linked_item_set_user(&itemA, (void *) 0);
jksoft 0:fccb789424fc 128 linked_item_set_user(&itemB, (void *) 0);
jksoft 0:fccb789424fc 129 linked_list_add(&testList, &itemA);
jksoft 0:fccb789424fc 130 linked_list_add(&testList, &itemB);
jksoft 0:fccb789424fc 131 linked_list_add_tail(&testList, &itemC);
jksoft 0:fccb789424fc 132 // linked_list_remove(&testList, &itemB);
jksoft 0:fccb789424fc 133 linked_item_t *it;
jksoft 0:fccb789424fc 134 for (it = (linked_item_t *) &testList; it ; it = it->next){
jksoft 0:fccb789424fc 135 if (it->next == &itemA) printf("Item A\n");
jksoft 0:fccb789424fc 136 if (it->next == &itemB) printf("Item B\n");
jksoft 0:fccb789424fc 137 if (it->next == &itemC) printf("Item C\n");
jksoft 0:fccb789424fc 138 /* if (it->next == &itemB){
jksoft 0:fccb789424fc 139 it->next = it->next;
jksoft 0:fccb789424fc 140 printf(" remove\n");
jksoft 0:fccb789424fc 141 } else {
jksoft 0:fccb789424fc 142 printf(" keep\n");
jksoft 0:fccb789424fc 143
jksoft 0:fccb789424fc 144 */
jksoft 0:fccb789424fc 145 }
jksoft 0:fccb789424fc 146 }
jksoft 0:fccb789424fc 147 #endif