Skip to content

Commit

Permalink
update MODI Play v1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
hanj-kim committed Feb 17, 2020
1 parent 70357ba commit ff1d703
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 24 deletions.
14 changes: 7 additions & 7 deletions 01.MODI Module example/01.Network/01.Network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 0 additions & 1 deletion 01.MODI Module example/06.Dial/06.Dial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ void setup() {

void loop() {
Serial.println("===============");

Serial.print("Dial :");
Serial.println(dial1.readDegree());
Serial.print("Dial Turn Speed :");
Expand Down
3 changes: 1 addition & 2 deletions 01.MODI Module example/07.Ultrasonic/07.Ultrasonic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ void setup() {

void loop() {
Serial.println("===============");

Serial.print("Dial :");
Serial.print("Ultra :");
Serial.println(ultra1.readDistance());
delay(100);
}
1 change: 0 additions & 1 deletion 01.MODI Module example/08.Infrared/08.Infrared.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ void setup() {

void loop() {
Serial.println("===============");

Serial.print("Proximity :");
Serial.println(ir1.readProximity());
delay(100);
Expand Down
4 changes: 2 additions & 2 deletions 03.MODI Creation example/03.MovingMouse/03.MovingMouse.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <MODI.h>

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;
Expand Down
19 changes: 17 additions & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -142,4 +146,15 @@ MODI_INT_PIN LITERAL1
MODI_CS_PIN LITERAL1
MODI_DIR_PIN LITERAL1

# Request
# 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

67 changes: 59 additions & 8 deletions src/MODI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace modi
MCP_CAN CAN(MODI_CS_PIN);
}
/*
* @Func :
* @Func : MODI_Manager
* @Brief :
* @Param :
* @RetVal:
Expand All @@ -27,7 +27,7 @@ MODI_Manager::MODI_Manager()
modulecnt = 0;
}
/*
* @Func :
* @Func : begin
* @Brief :
* @Param :
* @RetVal:
Expand All @@ -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:
Expand Down Expand Up @@ -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 :
Expand All @@ -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 */
/*
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion src/MODI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -51,6 +51,7 @@
#else
#define MODI_PRINT(...)
#define MODI_PRINTLN(...)
#define MODI_PRINT_F(...)
#endif

class Module
Expand Down Expand Up @@ -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 */
Expand Down
15 changes: 15 additions & 0 deletions src/MODI_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff1d703

Please sign in to comment.