Using screens with Control surface library

Hello!

I got a i2c lcd screen 20x4 (hd44780 library).

I was wondering about the use of screens on my control surface prototype..

  1. The option buying a 1306 SPI OLED screen (faster than i2c)...(i see examples on control surface library using this screen)
  2. Buying tactil nextion screen

Or using my i2c lcd screen 20x4 for showing potentiometer bars when moving the pots .or when the bank its switched
Maybe its possible to build a menu and enter a name for each potentiometer..

Honestly.. i am stuck at this point..i am able to show a graph bar when i am moving a potentiometer...but i don´t know how to integer on control surface.
Thanks

You'll have to explain what exactly you want to integrate.
If you want to display the value of a CCPotentiometer, for example, simply open the documentation and you'll see that there is a CCPotentiometer::getValue() function that you can use. For a 7-bit CCPotentiometer, it'll return a value in the range [0, 127].

Pieter

Ok…but i don feel confortable on english…i think this its my last hope you could understand me.
I have tried to record a video.

My paper prototype its a real shame but its ok you could understand me…if you want.

So i want to develope a midi footswitch for my personal use and i want to share who ever wants to build something similar…I really love arduino.

My next step its to know more things about this library… for example screens…

Now i am using every single CC from 1 to 127, its used…but i think i am newbie and should be another better ways to do that…
Imagine i got GAIN on CC67…Do you think would be possible to write GAIN on the screen?
Would be perfect if i could configure a name for each CC (Gain,volume,tone,rate,depth,etc,etc)

I have assumed i am newbie and Pieter P its the library author…so i understand i am a wasted time…but maybe theres another person who could help me or understand me.
Here its the code (absolutely not my code…i copy-paste)

#include <Control_Surface.h> 
USBMIDI_Interface usbmidi;    
#include <Arduino_Helpers.h> // Include the Arduino Helpers library.
#include <AH/Containers/ArrayHelpers.hpp>
#include <AH/Hardware/Button.hpp>
#include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>
#include <AH/Hardware/ExtendedInputOutput/SPIShiftRegisterOut.hpp>


Bank<8> bankpedal(4); 
Bank<8> bankamp(4);  


CD74HC4067 mux2 = {
  8,           
  {9, 10, 11, 12}, 
 
};

CCButtonLatched futton [] = {          
  { mux2.pin(0), { 77, CHANNEL_1 } },    
  { mux2.pin(1), { 81, CHANNEL_2 } }, 
  { mux2.pin(2), { 85, CHANNEL_3 } },                                                   
  { mux2.pin(3), { 89, CHANNEL_4 } },
  { mux2.pin(4), { 93, CHANNEL_5 } },
  { mux2.pin(5), { 97, CHANNEL_6 } },
  { mux2.pin(6), { 101, CHANNEL_7 } },
  { mux2.pin(7), { 105, CHANNEL_8 } },
 }; 


CCButtonLatched futton2 [] = {  
  { mux2.pin(8), { 84, CHANNEL_1 } },    
  { mux2.pin(9), { 86, CHANNEL_2 } }, 
  { mux2.pin(10), { 87, CHANNEL_3 } },                                                   
  { mux2.pin(11), { 88, CHANNEL_4 } },
  { mux2.pin(12), { 90, CHANNEL_5 } },
  { mux2.pin(13), { 91, CHANNEL_6 } },
  { mux2.pin(14), { 92, CHANNEL_7 } },
  { mux2.pin(15), { 94, CHANNEL_8 } },

};


CD74HC4067 mux3 = {
  A15,            
  {A14, A13, A12, A11}, 
  
};

CCPotentiometer pots3 [] = {

  {mux3.pin(4), 74},
  {mux3.pin(5), 75},
  {mux3.pin(6), 76},
  {mux3.pin(7), 78},
  {mux3.pin(12), 79},
  {mux3.pin(13), 80},
  {mux3.pin(14), 82},
  {mux3.pin(15), 83},
  

};

Bankable::CCButtonLatched<8>  bankbuttons [] = {  
  { bankpedal, 7, 77, },  
  //{ bankpedal, 6, 91, },
  };

Bankable::CCPotentiometer pots[] = {   
  
  {bankamp, mux3.pin(8), 1},
  {bankamp, mux3.pin(9), 3},
  {bankamp, mux3.pin(10), 4},
  {bankamp, mux3.pin(11), 6},

  };
 
Bankable::CCPotentiometer pots2[] = {    
  
  {bankpedal, mux3.pin(0), 37},
  {bankpedal, mux3.pin(1), 38},
  {bankpedal, mux3.pin(2), 39},
  {bankpedal, mux3.pin(3), 40},

  };
IncrementDecrementSelectorLEDs<8> bankSelector = {   
  bankpedal,
  {5, 6},         // button pins
  {30, 31, 32, 33, 34, 35, 36, 37}, // LED pins
  }; 

IncrementDecrementSelectorLEDs<8> bankSelector2 = {   
  bankamp,
  {18, 19},         // button pins
  {38, 43, 44, 41, 42, 39, 40, 45}, // LED pins
  };



const pin_t ledPins[] = { 22, 23, 24, 25, 26, 27, 28, 29 };

template <class T, size_t N> constexpr size_t length(T (&)[N]) { return N; }

static_assert(length(futton) == length(ledPins),
              "Error: requires same number of buttons as LEDs");


void setup() {

    Control_Surface.begin();
 for (auto pin : ledPins)  // Set the pinMode to output for all LEDs
      pinMode(pin, OUTPUT);


 }

void loop() {
  // put your main code here, to run repeatedly:
  Control_Surface.loop();
 for (size_t i = 0; i < length(futton); ++i)
      // Update the LED states to reflect the toggled switch states
      digitalWrite(ledPins[i], futton[i].getState() ? LOW : HIGH);

 }

chichiforever:
Now i am using every single CC from 1 to 127

120 to 127 are not CC numbers, they have a special meaning.

It's still not entirely clear to me where you're stuck. The library you're using for your display should have examples that show how to print text and numbers to the display. Once you have that working, interfacing it with Control Surface should be trivial, most of Control Surfaces classes have getters to access the values of buttons or potentiometers, so you can just print these values to your display in any way you want.

Control Surface does not store the names of Control Change addresses, only the number. If you want to print CC names to the display, you'll have to provide that logic yourself. Simply write a lookup table, preferably in PROGMEM (see Control-Surface/MCUNameFromNoteNumber.cpp at new-input · tttapa/Control-Surface · GitHub for inspiration).

chichiforever:
Here its the code (absolutely not my code..i copy-paste)

That code is way too long if you're stuck. Start with the simplest sketch possible, e.g. a single CCPotentiometer without banks.

That code is way too long if you're stuck. Start with the simplest sketch possible, e.g. a single CCPotentiometer without banks.

Yes..this its the second time you told me to do that way

Now i am busy (house-moving). But i will try to make it..

Control surface its so easy to use..and my midi footswitch its doing what i have dreamed one month ago (:-D) but hey! i want to know each little thing...(at least things that i am able to know today) on control.surface and arduino.

For people starting to understand i think this videos are helpful..
I know this it´s like sesame street .but it´s my actual level.. this guy it´s helping me programing on arduino
Do you know something that might be helpful for understand C++ or the library documentation? (i understand years of practice , yeah..)...

For example...now i know PROGMEM and the chance to change strings of letters or things like that and store into flash memory..and you told me i can call this things on control surface.
And I know i could build a menu on the screen..but now only blows my mind
I don´t know the first step or where its the floor :smiley: .

Ok.. Progmem its my first step..thanks for the info..was inspired for me
Thanks

chichiforever:
Do you know something that might be helpful for understand C++ or the library documentation? (i understand years of practice , yeah..)...

I'd highly recommend following some kind of structured course or a book. There are free resources online, such as learncpp.com, and many video lectures as well. Some people learn better using a textbook, others might prefer videos, that's a personal choice you'll have to make. There's a huge variety in the quality of YouTube videos, so it might be worth reading the comments or searching for reviews before investing time in them (do keep in mind that people in the comments of videos aimed at beginners are often beginners themselves, so they cannot really judge the quality of the video).

Arduino users often use a trial-and-error technique, copying and pasting code they don't understand and then they get stuck. This is a really inefficient approach. Taking the time to actually follow a course and doing simple practice problems really pays off in the long run, even though it might not be as exciting as starting with a huge project.

As a personal rule, I'd recommend only ever using code you completely understand: you should be able to understand every word, every operator in the code before pasting it into your own projects. If you find a sketch online, you can try it out and experiment with it a bit, and then look up the concepts and language constructs it uses. You don't have to understand it in full detail yet, a high level understanding is enough when you first come across a new concept, but you should be able to explain to yourself why the author decided to use a certain feature, and what it does in the context of the (example) code.

You can't really do this in isolation, of course, you need to get the basics of the C++ language down first, which is why I recommend a structured resource like courses or books. You can't start reading literature in a foreign language without studying some basic vocabulary and grammar first.
You need to understand the C++ syntax, variables, scope, data types, arrays, functions, classes, etc. These concepts are covered in any beginner-level C++ course or book.
Once you understand how classes, constructors and member functions work, you should be able to understand the Control Surface documentation.

chichiforever:
For example...now i know PROGMEM and the chance to change strings of letters or things like that and store into flash memory..and you told me i can call this things on control surface.
And I know i could build a menu on the screen..but now only blows my mind
I don´t know the first step or where its the floor :smiley: .

Ok.. Progmem its my first step..thanks for the info..was inspired for me

Don't start with progmem, that's an implementation detail.
Start with a small number of simple strings first, worry about efficiently storing a large number of strings later.

I think i have lost my mind since covid…because i am so excited thinking about starting to learn c++ (when i was a child i´ve always dreamed about a spectrum sinclair but only knew atari 2600 :slight_smile:

You know…its something similar looking to climb the everest and you dont know the start track point but now i can start walking and watching the sides of the mountain :o .
i will try to find and walk the road.

Edit: Visual studio community and Visual Studio code will be my IDE´s.
Ubuntu will be my option for writing and testing when i finish the book learn.cpp.

Thanks Pieter.P really appreciated your help.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.