diff --git a/01.MODI Module example/01.Network/01.Network.ino b/01.MODI Module example/01.Network/01.Network.ino index 4221c4c..dd12fa1 100644 --- a/01.MODI Module example/01.Network/01.Network.ino +++ b/01.MODI Module example/01.Network/01.Network.ino @@ -21,30 +21,30 @@ void setup() { void loop() { // put your main code here, to run repeatedly: - if(network1.readEvent() == 1) + if(network1.readEvent() == EVENT_BUTTON_PRESSED) { Serial.println("Button Pressed"); - network1.writeEvent(1); // buzzer on + network1.writeEvent(EVENT_BUZZER_ON); // buzzer on } - else if(network1.readEvent() == 2) // joystick up + else if(network1.readEvent() == EVENT_JOYSTICK_UP) // joystick up { Serial.println("Joystick Up Pressed"); } - else if(network1.readEvent() == 3) // joystick down + else if(network1.readEvent() == EVENT_JOYSTICK_DOWN) // joystick down { Serial.println("Joystick Down Pressed"); } - else if(network1.readEvent() == 4) // joystick right + else if(network1.readEvent() == EVENT_JOYSTICK_RIGHT) // joystick right { Serial.println("Joystick Right Pressed"); } - else if(network1.readEvent() == 5) // joystick left + else if(network1.readEvent() == EVENT_JOYSTICK_LEFT) // joystick left { Serial.println("Joystick Left Pressed"); } else { - network1.writeEvent(0); // buzzer off + network1.writeEvent(EVENT_BUZZER_OFF); // buzzer off } delay(100); } \ No newline at end of file diff --git a/01.MODI Module example/06.Dial/06.Dial.ino b/01.MODI Module example/06.Dial/06.Dial.ino index 5eb0083..9d3fab7 100644 --- a/01.MODI Module example/06.Dial/06.Dial.ino +++ b/01.MODI Module example/06.Dial/06.Dial.ino @@ -21,7 +21,6 @@ void setup() { void loop() { Serial.println("==============="); - Serial.print("Dial :"); Serial.println(dial1.readDegree()); Serial.print("Dial Turn Speed :"); diff --git a/01.MODI Module example/07.Ultrasonic/07.Ultrasonic.ino b/01.MODI Module example/07.Ultrasonic/07.Ultrasonic.ino index 0204977..9c43921 100644 --- a/01.MODI Module example/07.Ultrasonic/07.Ultrasonic.ino +++ b/01.MODI Module example/07.Ultrasonic/07.Ultrasonic.ino @@ -20,8 +20,7 @@ void setup() { void loop() { Serial.println("==============="); - - Serial.print("Dial :"); + Serial.print("Ultra :"); Serial.println(ultra1.readDistance()); delay(100); } \ No newline at end of file diff --git a/01.MODI Module example/08.Infrared/08.Infrared.ino b/01.MODI Module example/08.Infrared/08.Infrared.ino index fee2489..d39dbea 100644 --- a/01.MODI Module example/08.Infrared/08.Infrared.ino +++ b/01.MODI Module example/08.Infrared/08.Infrared.ino @@ -20,7 +20,6 @@ void setup() { void loop() { Serial.println("==============="); - Serial.print("Proximity :"); Serial.println(ir1.readProximity()); delay(100); diff --git a/03.MODI Creation example/03.MovingMouse/03.MovingMouse.ino b/03.MODI Creation example/03.MovingMouse/03.MovingMouse.ino index 527c3f7..da078b4 100644 --- a/03.MODI Creation example/03.MovingMouse/03.MovingMouse.ino +++ b/03.MODI Creation example/03.MovingMouse/03.MovingMouse.ino @@ -1,7 +1,7 @@ #include -const unsigned int BUTTON_ID = 0xF55; // please modify id to your module's id -const unsigned int MOTOR_ID = 0xB5; +const unsigned int BUTTON_ID = 0xAC0; // please modify id to your module's id +const unsigned int MOTOR_ID = 0x84C; /* module */ Button button1; diff --git a/keywords.txt b/keywords.txt index 48696c2..6b6aa68 100644 --- a/keywords.txt +++ b/keywords.txt @@ -119,9 +119,13 @@ writeMelody KEYWORD2 # Setup Module Function readData KEYWORD2 readEvent KEYWORD2 +readSlider_Left KEYWORD2 +readSlider_Right KEYWORD2 +readDialTurn KEYWORD2 +readTimeout KEYWORD2 writeData KEYWORD2 writeEvent KEYWORD2 - +void writeCamera KEYWORD2 ####################################### # PREPROCESSOR (KEYWORD3) @@ -142,4 +146,15 @@ MODI_INT_PIN LITERAL1 MODI_CS_PIN LITERAL1 MODI_DIR_PIN LITERAL1 -# Request \ No newline at end of file +# Request + +# MODIPLAY +EVENT_BUTTON_PRESSED LITERAL1 +EVENT_JOYSTICK_UP LITERAL1 +EVENT_JOYSTICK_DOWN LITERAL1 +EVENT_JOYSTICK_RIGHT LITERAL1 +EVENT_JOYSTICK_LEFT LITERAL1 + +EVENT_BUZZER_ON LITERAL1 +EVENT_BUZZER_OFF LITERAL1 + diff --git a/src/MODI.cpp b/src/MODI.cpp index f41d890..e7e0e49 100644 --- a/src/MODI.cpp +++ b/src/MODI.cpp @@ -17,7 +17,7 @@ namespace modi MCP_CAN CAN(MODI_CS_PIN); } /* - * @Func : + * @Func : MODI_Manager * @Brief : * @Param : * @RetVal: @@ -27,7 +27,7 @@ MODI_Manager::MODI_Manager() modulecnt = 0; } /* - * @Func : + * @Func : begin * @Brief : * @Param : * @RetVal: @@ -52,10 +52,10 @@ void MODI_Manager::begin(void) setModulePnP(MODI.moduleID[cnt],MODULE_PNP_OFF); } /* Set Direction pin as input */ - pinMode(MODI_DIR_PIN,INPUT); + //pinMode(MODI_DIR_PIN,INPUT); } /* - * @Func : + * @Func : begin * @Brief : * @Param : * @RetVal: @@ -346,6 +346,46 @@ uint32_t Network::readEvent(void) { return getPropertyInt(key(),PROP_NETWORK_EVENT); } +/* + * @Func : + * @Brief : + * @Param : + * @RetVal: + */ +uint32_t Network::readSlider_Left(void) +{ + return getPropertyInt(key(),PROP_NETWORK_SLIDER_LEFT); +} +/* + * @Func : + * @Brief : + * @Param : + * @RetVal: + */ +uint32_t Network::readSlider_Right(void) +{ + return getPropertyInt(key(),PROP_NETWORK_SLIDER_RIGHT); +} +/* + * @Func : + * @Brief : + * @Param : + * @RetVal: + */ +uint32_t Network::readDialTurn(void) +{ + return getPropertyInt(key(),PROP_NETWORK_DIAL); +} +/* + * @Func : + * @Brief : + * @Param : + * @RetVal: + */ +uint32_t Network::readTimeout(void) +{ + return getPropertyInt(key(),PROP_NETWORK_TIMER); +} /* * @Func : * @Brief : @@ -368,6 +408,17 @@ void Network::writeEvent(int32_t data) setProperty64(key(),PROP_NETWORK_EVENT,data); return; } +/* + * @Func : + * @Brief : + * @Param : + * @RetVal: + */ +void Network::writeCamera(int32_t data) +{ + setProperty64(key(),PROP_NETWORK_CAM,data); + return; +} /* 1. Environment Module */ /* @@ -1094,10 +1145,10 @@ void Display::writeState(uint8_t state) void Display::writePosition(int16_t X, int16_t Y) { uint8_t data[8]; - data[0] = ((X >> 0x00FFU) >> 0); - data[1] = ((X >> 0xFF00U) >> 8); - data[2] = ((Y >> 0x00FFU) >> 0); - data[3] = ((Y >> 0xFF00U) >> 8); + data[0] = ((X & 0x00FFU) >> 0); + data[1] = ((X & 0xFF00U) >> 8); + data[2] = ((Y & 0x00FFU) >> 0); + data[3] = ((Y & 0xFF00U) >> 8); setProperty(key(),PROP_DISPLAY_RESET,data); return; } diff --git a/src/MODI.h b/src/MODI.h index 23b285f..15da81f 100644 --- a/src/MODI.h +++ b/src/MODI.h @@ -22,7 +22,7 @@ #define MODI_DEBUG_MODE 1 /* */ -#define MODI_MAX_MODULE_NUM 5 +#define MODI_MAX_MODULE_NUM 2 /* Pin out for Arduino MKR Series */ #if defined(ARDUINO_ARCH_SAMD) @@ -51,6 +51,7 @@ #else #define MODI_PRINT(...) #define MODI_PRINTLN(...) + #define MODI_PRINT_F(...) #endif class Module @@ -122,9 +123,14 @@ class Network :public Module, public PropertySender uint32_t readData(void); uint32_t readEvent(void); + uint32_t readSlider_Left(void); + uint32_t readSlider_Right(void); + uint32_t readDialTurn(void); + uint32_t readTimeout(void); void writeData(int32_t data); void writeEvent(int32_t data); + void writeCamera(int32_t data); }; /* 1. Environment Module */ diff --git a/src/MODI_property.h b/src/MODI_property.h index 2f5f098..cd6f789 100644 --- a/src/MODI_property.h +++ b/src/MODI_property.h @@ -89,6 +89,21 @@ #define PROP_NETWORK_DATA 2 #define PROP_NETWORK_EVENT 3 +#define PROP_NETWORK_JOYSTICK 3 +#define PROP_NETWORK_DIAL 4 +#define PROP_NETWORK_SLIDER_LEFT 5 +#define PROP_NETWORK_SLIDER_RIGHT 6 +#define PROP_NETWORK_TIMER 7 +#define PROP_NETWORK_CAM 257 + +#define EVENT_BUTTON_PRESSED 100 +#define EVENT_JOYSTICK_UP 20 +#define EVENT_JOYSTICK_DOWN 30 +#define EVENT_JOYSTICK_RIGHT 40 +#define EVENT_JOYSTICK_LEFT 50 + +#define EVENT_BUZZER_ON 1 +#define EVENT_BUZZER_OFF 0 #define MODULE_PNP_OFF 0 #define MODULE_PNP_ON 1