This post covers the required code insertions to the main Arduino file within its main loop._

As stated previously: The “shell” Softata code for the Bargraph Display has been implemented. This includes code in the Arduino sketch as well as in the minimal mirroring code in SoftataLib. _The Console app did not require any new code. The shell code does not implement the required functionality, but includes empty methods that return true where the functionality can be implemented. The Arduino sketch builds and runs without error with these additions. The C# SoftataLib code compiles and the display can be chosen in the Console app where the app runs and completes without error. A comparison was made of the repository before and after the addition of the “shell” code for the display and can be viewed here

The object of this specific exercise is to provide a template for adding devices, specifically for adding displays to Softata.

The previous post covered specifications for a new display particularly in terms of enum constants and class name. This post covers the required “hooks” for the display in the Softata Arduino sketch.

2. Display Method Calls

The device type specific code in softata.ino is in the cmd switch statement. There is a case of each device type. For each device type case there is a “sub” switch statement for each of the enum GroveDisplayCmds commands. As far as is possible, the case for each GroveDisplayCmds command is not specific for each actual device and so does not require any device specific code. The exceptions are GetPins and the instantiation of the specific display class. The d_tbdCMD command is there just for consistency with earlier code. For where specifics are required there is a switch statement using the param parameter. param specifies the actual display according to the enum GroveDisplay generated list of displays.

Displays are case 0xf1:

case 0xF1: //Grove Displays

For each of the following insert the BARGRAPH`` after theNEOPIXEL`` case.

  • Command: case d_getpinsCMD:
          case BARGRAPH:
              client.print(Custom_Bargraph::GetPins());
              break;
    
  • Command: case d_tbdCMD:
          case BARGRAPH:
              //Custom_Bargraph 
              break;
    
  • Command: case d_setupCMD:
          case BARGRAPH:
          {
              grove_Display  = new Custom_Bargraph();
              _done = true;
          }
          break;
    

Nb: The grove_Display is the general Display class, not the device specific class.

The rest of the display commands are “generic” at this level. Polymorphism is used to access display method. Even Misc() is generic. The additional device specific functions at determined in actual display class.

Next: The Display class.


 TopicSubtopic
   
 This Category Links 
Category:Softata Index:Softata
  Next: > Softata - Adding a new display
<  Prev:   Softata - Adding a new display