OSD Battery Monitoring for Helder's AIO Boards

Various user-contributed guides for hardware-related things
JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Sun May 13, 2018 11:49 am

Thank again!

If i get it right i could leave it as it is since, from what i read, it is already set on A0.. there is no need to write in my pin number(21) right?

Also i will change led pin to 11(since that's my led pin) and probably get rid of pin 15 and 16 since if i read it correctly thet are not used in the original script..

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 37 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Sun May 13, 2018 1:47 pm

A0 is indeed set as analog in in this sketch.
Correct 11 is free (in the sketch that is, the leonardo pro micro does not have a pin 11 ;) ) and 15/16 are not used.
Ah now i get it, you are using a teensy 2.0, this one got a lot more pins than a Pro Micro (mini arduino leonardo).
So you have to check wich pins the teensy uses for analog input (i have no teensy so i cannot tell you this) and change the A0 in analogRead(A0) into the pin number used by teensy.

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Sun May 13, 2018 2:58 pm

this is the code I changed. Unfortunatelly it doesn't compile... i also tried to compile the original script but it returns the same error ( to me it looks like a formatting error, indentation and brackets. i just copied and pasted the code in the other thread)

Arduino:1.8.5 (Windows 10), TD: 1.41, Scheda:"Teensy 2.0, Keyboard + Mouse + Joystick, 16 MHz, US English"

Opzioni di compilazione cambiate, ricompilo tutto
C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino: In function 'void setup()':

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:37:1: error: 'Gamepad' was not declared in this scope

Gamepad.begin();

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino: In function 'void loop()':

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:47:3: error: 'Gamepad' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_CENTERED);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:47:17: error: 'GAMEPAD_DPAD_CENTERED' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_CENTERED);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:49:19: error: 'GAMEPAD_DPAD_DOWN' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_DOWN);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:51:21: error: 'GAMEPAD_DPAD_DOWN_LEFT' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_DOWN_LEFT);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:53:21: error: 'GAMEPAD_DPAD_DOWN_RIGHT' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_DOWN_RIGHT);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:56:19: error: 'GAMEPAD_DPAD_UP' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_UP);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:58:21: error: 'GAMEPAD_DPAD_UP_LEFT' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_UP_LEFT);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:60:21: error: 'GAMEPAD_DPAD_UP_RIGHT' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_UP_RIGHT);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:63:19: error: 'GAMEPAD_DPAD_LEFT' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_LEFT);

^

C:\Users\marley\Desktop\GamepadNoAnalog-HID\GamepadNoAnalog-HID.ino:65:19: error: 'GAMEPAD_DPAD_RIGHT' was not declared in this scope

Gamepad.dPad1(GAMEPAD_DPAD_RIGHT);

^

Errore durante la compilazione per la scheda Teensy 2.0.

Questo report potrebbe essere più ricco di informazioni abilitando l'opzione
"Mostra un output dettagliato durante la compilazione"
in "File -> Impostazioni"





Code: Select all

#include "HID-Project.h"

#define NUM_BUTTONS 17

#define BTN_UP 0
#define BTN_DOWN 1
#define BTN_LEFT 2
#define BTN_RIGHT 3
#define BTN_A 4
#define BTN_START 5
#define BTN_Y 6
#define BTN_L1 7
#define BTN_X 8
#define BTN_R1 9
#define BTN_B 10
#define BTN_SELECT 12

const int ledPin =  11;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
char i;

void setup() 
{
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(11, OUTPUT);
Gamepad.begin();
Serial.begin(115200);  
}

void loop() 
{
  bool down = !digitalRead(BTN_DOWN);
  bool up = !digitalRead(BTN_UP);
  bool left = !digitalRead(BTN_LEFT);
  bool right = !digitalRead(BTN_RIGHT);
  Gamepad.dPad1(GAMEPAD_DPAD_CENTERED);
  if(down) {
    Gamepad.dPad1(GAMEPAD_DPAD_DOWN);
    if(left) {
      Gamepad.dPad1(GAMEPAD_DPAD_DOWN_LEFT);
    }if(right) {
      Gamepad.dPad1(GAMEPAD_DPAD_DOWN_RIGHT);
    }
  }else if(up) {
    Gamepad.dPad1(GAMEPAD_DPAD_UP);
    if(left) {
      Gamepad.dPad1(GAMEPAD_DPAD_UP_LEFT);
    }if(right) {
      Gamepad.dPad1(GAMEPAD_DPAD_UP_RIGHT);
    }
  }else if(left) {
    Gamepad.dPad1(GAMEPAD_DPAD_LEFT);
  }else if(right) {
    Gamepad.dPad1(GAMEPAD_DPAD_RIGHT);
  }
  
  for(int i = 4; i <16; i++) 
{
    if(!digitalRead(i)) {
   Gamepad.press(i);
    }else {
      Gamepad.release(i);
    }
  }
  Gamepad.write();
int sensorValue = analogRead(A0); // read the input on analog pin 0:
//Serial.println(sensorValue); // print out the value you read
float voltage = sensorValue * (4.88 / 1023.00); 
//Serial.println(voltage);
if(Serial.available())
{
i=Serial.read();
}
if(i=='1')
{
Serial.println(sensorValue);
}
i='0';

if (voltage > 4.5) 
 {
 digitalWrite(16, HIGH);
 }
else
{
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }
    digitalWrite(ledPin, ledState);
}
  }
  delay(10);
}

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 37 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Sun May 13, 2018 4:22 pm

It seems you're missing a library, namely this one "vHID-Project.h"
You can get it here http://downloads.arduino.cc/libraries/g ... -2.4.4.zip

Gizard
Posts: 68
Joined: Sat Feb 03, 2018 8:37 am
Has thanked: 6 times
Been thanked: 8 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Gizard » Sun May 13, 2018 5:07 pm

Where can I get Helder’s board? I am planning on using a tinkerboy right now.
Check out my bluetooth speaker in an altoids tin! https://sudomod.com/forum/viewtopic.php?t=7274

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Sun May 13, 2018 5:26 pm

Wailer wrote:
Sun May 13, 2018 4:22 pm
It seems you're missing a library, namely this one "vHID-Project.h"
You can get it here http://downloads.arduino.cc/libraries/g ... -2.4.4.zip
I implemented the library and some more
now this is the error, it is so long that it wiont fit in the message, here are the first few lines


tomorrow i will reinstall arduino and teensydoino and redo everithing from the beginning,

would it be possible to add instead a ads1015 module and work only on the raspy side using mintymonitor? i know it is integrated in the teensy but at this point would save me the headache..

Code: Select all

Arduino:1.8.5 (Windows 10), TD: 1.41, Scheda:"Teensy 2.0, Keyboard + Mouse + Joystick, 16 MHz, US English"

In file included from C:\Users\marley\Documents\Arduino\libraries\HID-Project\src/SingleReport/USBAPI.h:33:0,

                 from C:\Users\marley\Documents\Arduino\libraries\HID-Project\src/SingleReport/PluggableUSB.h:23,

                 from C:\Users\marley\Documents\Arduino\libraries\HID-Project\src/SingleReport/SingleAbsoluteMouse.h:28,

                 from C:\Users\marley\Documents\Arduino\libraries\HID-Project\src/HID-Project.h:39,

                 from C:\Users\marley\Desktop\sketch_may13a\sketch_may14a\sketch_may14a.ino:1:

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 37 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Mon May 14, 2018 12:32 am

I can understand your headache... Arduino software can do that sometimes...
The errors it throws can be very cryptic...

The first error line (look for the line number) is mostly the line where the trouble starts, everything that follows is (most of the time) irrelevant (one ; forgotten can cause a sh*tload of following errors 😉).

You are using ide 1.8.5. so that's ok.
Al boards with atmega 32u4/90usb should be supported so the teensy can't be the problem, that is if you are using the 2.0 (or the ++ version).
Do you have the right board selected? You can only upload this sketch to supported boards (the software checks this an gives you a error if not).

The ads1015 is a solution (also for your headache), check the forums on how to use this.

Like i said, i used a Leonardo compatible board i have never worked with a teensy.
Maybe there are other forum members who can shed some light on this?

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Mon May 14, 2018 4:30 am

Hi,
Yes the board is compatible.. a was able to upload the sketch done by wermy.. this one doesn want to compile.. i will try again tonight by doing a full reinstall of the programs on my pc and report back.. thanks alot for your support and, most of all, patience..

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 37 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Mon May 14, 2018 4:48 am

I loaded the sketch and selected the teensy as board, and yup, errors galore :evil: . (same code leo as board=no problem :roll: ).
It seems to program the teensy with this sketch you need a lot more libraries...
So i guess it's not in your software (saves you a reinstall).

There should be a lot more forum members using a teensy as a battery monitor...
Come on guys...

Btw where did you find Wermy's sketch?

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Mon May 14, 2018 5:01 am

This is the link http://sudomod.com/wp-content/uploads/2 ... y_Zero.zip i found it on his gbz guide.. it handles key presses only..

Yesterday i loded all the libraries missing but than i started getting the 10miles long error i told you about...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest