Skip to content

Commit

Permalink
Merge pull request #25 from dmadison/structure-rework
Browse files Browse the repository at this point in the history
Major structure rework
  • Loading branch information
dmadison authored Jun 14, 2018
2 parents ba3b6ef + c0332a0 commit 8ae3b02
Show file tree
Hide file tree
Showing 31 changed files with 902 additions and 770 deletions.
16 changes: 8 additions & 8 deletions examples/Any/IdentifyController/IdentifyController.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ void setup() {
controller.begin();
controller.connect();

NXC_ControllerType conType = controller.getConnectedID();
ExtensionType conType = controller.getConnectedID();

switch (conType) {
case(NXC_NoController):
case(ExtensionType::NoController):
Serial.println("No controller detected");
break;
case(NXC_UnknownController):
case(ExtensionType::UnknownController):
Serial.println("Unknown controller detected");
break;
case(NXC_Nunchuk):
case(ExtensionType::Nunchuk):
Serial.println("Nunchuk detected!");
break;
case(NXC_ClassicController):
case(ExtensionType::ClassicController):
Serial.println("Classic Controller detected!");
break;
case(NXC_GuitarController):
case(ExtensionType::GuitarController):
Serial.println("Guitar controller connected!");
break;
case(NXC_DrumController):
case(ExtensionType::DrumController):
Serial.println("Drum set controller connected!");
break;
case(NXC_DJTurntable):
case(ExtensionType::DJTurntableController):
Serial.println("DJ turntable connected!");
break;
}
Expand Down
13 changes: 6 additions & 7 deletions examples/Any/MultipleTypes/MultipleTypes.ino
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <NintendoExtensionCtrl.h>

ExtensionData busData(Wire); // Shared data for the controller on the 'Wire' bus
ExtensionController controller(busData); // Generic type: works with any ID, and requests the max # of bytes possible
ExtensionController controller; // Port for communicating with extension controllers

Nunchuk nchuk(busData);
ClassicController classic(busData);
Nunchuk::Data nchuk(controller); // Read Nunchuk formatted data from the port
ClassicController::Data classic(controller); // Read Classic Controller formatted data from the port

void setup() {
Serial.begin(115200);
Expand All @@ -20,13 +19,13 @@ void loop() {
boolean success = controller.update(); // Get new data from the controller

if (success == true) { // We've got data!
NXC_ControllerType conType = controller.getConnectedID();
ExtensionType conType = controller.getConnectedID();

switch (conType) {
case(NXC_Nunchuk):
case(ExtensionType::Nunchuk):
nchuk.printDebug();
break;
case(NXC_ClassicController):
case(ExtensionType::ClassicController):
classic.printDebug();
break;
default:
Expand Down
10 changes: 5 additions & 5 deletions examples/DJ/DJ_Demo/DJ_Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ void loop() {
}

// Read the turntable config
NXC_DJTurntable_Configuration config = dj.getTurntableConfig();
DJTurntableController::TurntableConfig config = dj.getTurntableConfig();

Serial.print("Connected turntables: ");

switch (config) {
case(NXC_DJTurntable_BaseOnly):
case(DJTurntableController::TurntableConfig::BaseOnly):
Serial.println("None");
break;
case(NXC_DJTurntable_Left):
case(DJTurntableController::TurntableConfig::Left):
Serial.println("Left");
break;
case(NXC_DJTurntable_Right):
case(DJTurntableController::TurntableConfig::Right):
Serial.println("Right");
break;
case(NXC_DJTurntable_Both):
case(DJTurntableController::TurntableConfig::Both):
Serial.println("Both");
break;
}
Expand Down
16 changes: 8 additions & 8 deletions examples/Drums/Drums_Demo/Drums_Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ void loop() {
if (drums.velocityAvailable()) {
Serial.print("available! ");

NXC_DrumVelocityID id = drums.velocityID();
DrumController::VelocityID id = drums.velocityID();
switch (id) {
case(NXC_Drum_None):
case(DrumController::None):
Serial.print("No Drum"); // Should never happen, hopefully
break;
case(NXC_Drum_Red):
case(DrumController::Red):
Serial.print("Red");
break;
case(NXC_Drum_Blue):
case(DrumController::Blue):
Serial.print("Blue");
break;
case(NXC_Drum_Green):
case(DrumController::Green):
Serial.print("Green");
break;
case(NXC_Drum_Yellow):
case(DrumController::Yellow):
Serial.print("Yellow");
break;
case(NXC_Drum_Orange):
case(DrumController::Orange):
Serial.print("Orange");
break;
case(NXC_Drum_Pedal):
case(DrumController::Pedal):
Serial.print("Bass pedal");
break;
}
Expand Down
58 changes: 29 additions & 29 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NintendoExtensionCtrl KEYWORD1

# Controller Base Classes
ExtensionController KEYWORD1
ExtensionData KEYWORD1
Data KEYWORD1

# Wii Controllers
Nunchuk KEYWORD1
Expand All @@ -25,9 +25,9 @@ NESMiniController KEYWORD1
SNESMiniController KEYWORD1

# Enumerations
NXC_ControllerType KEYWORD1
NXC_DrumVelocityID KEYWORD1
NXC_DJTurntable_Configuration KEYWORD1
ExtensionType KEYWORD1
VelocityID KEYWORD1
TurntableConfig KEYWORD1

# Sub-Classes
TurntableExpansion KEYWORD1
Expand All @@ -50,9 +50,6 @@ reset KEYWORD2

getConnectedID KEYWORD2
getControlData KEYWORD2
getControlBit KEYWORD2

setEnforceID KEYWORD2

printDebug KEYWORD2
printDebugID KEYWORD2
Expand Down Expand Up @@ -201,25 +198,28 @@ getNumTurntables KEYWORD2
#######################################

# Controller Identities
NXC_NoController LITERAL1
NXC_UnknownController LITERAL1
NXC_Nunchuk LITERAL1
NXC_ClassicController LITERAL1
NXC_GuitarController LITERAL1
NXC_DrumController LITERAL1
NXC_DJTurntable LITERAL1

# Drum Velocity IDs
NXC_Drum_None LITERAL1
NXC_Drum_Red LITERAL1
NXC_Drum_Blue LITERAL1
NXC_Drum_Green LITERAL1
NXC_Drum_Yellow LITERAL1
NXC_Drum_Orange LITERAL1
NXC_Drum_Pedal LITERAL1

# DJ Turntable Configurations
NXC_DJTurntable_BaseOnly LITERAL1
NXC_DJTurntable_Left LITERAL1
NXC_DJTurntable_Right LITERAL1
NXC_DJTurntable_Both LITERAL1
NoController LITERAL1
AnyController LITERAL1
UnknownController LITERAL1

## ( These IDs are commented out, as these interfere with the class definitions )
# Nunchuk LITERAL1
# ClassicController LITERAL1
# GuitarController LITERAL1
# DrumController LITERAL1
# DJTurntableController LITERAL1

# Drum Velocity IDs (Scoped to class)
None LITERAL1
Red LITERAL1
Blue LITERAL1
Green LITERAL1
Yellow LITERAL1
Orange LITERAL1
Pedal LITERAL1

# DJ Turntable Configurations (Scoped to class)
BaseOnly LITERAL1
Left LITERAL1
Right LITERAL1
Both LITERAL1
69 changes: 0 additions & 69 deletions src/ClassicController.h

This file was deleted.

Loading

0 comments on commit 8ae3b02

Please sign in to comment.