Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

[Solved] invalid types for subscript array

Greetings,
    I'm pretty bad at AVR C and was curious if anyone could help me with this?

    I'm using the Teensy Keyboard library to try and automate BIOS configuration. I have no idea what data type KEY_F2 is for example and how that should be handled. I can't seem to find any references besides basic usages of the library.

Long error desc: https://pastebin.com/pqPrDF80



PHP Code

<?php 
const int ledPin = 13;
const 
byte hp_bios_key = KEY_F10;
const 
byte dell_bios_key = KEY_F2;
const 
byte lenovo_bios_key = KEY_F1;

const 
byte hp_dell_netboot_key = KEY_F12;
const 
byte lenovo_netboot_key = KEY_F3;

void setup() {
 
 pinMode(ledPin, OUTPUT);
 
 for (int i=0; i < 10; i++) {
 
   digitalWrite(ledPin, HIGH);
 
   delay(100);
 
   digitalWrite(ledPin, LOW);
 
   delay(100);
 
 }
 
 //Keyboard.press(KEY_RIGHT);
 
 //delay(250);
 
 //Keyboard.release(KEY_RIGHT);
}

void Execute(byte keys, int repeats, int delays, int lens){
 
 byte key_to_press;
 
 int key_repeat;
 
 int key_delay;

 
 for (int s = 0; s < lens; s++) {
 
   key_to_press = keys[s];
 
   key_repeat = repeats[s];
 
   key_delay = delays[s];

 
   for (r = 0; r < key_repeats; r++) {
 
     Keyboard.press(key_to_press);
 
     delay(key_delay);
 
     Keyboard.release(key_to_press);
 
     delay(key_delay / 2);
 
   }
 
 }
}

void HP(byte process) {

 
 if (process == 1) {
 
   byte _keys[4]    = [  KEY_TAB, KEY_ENTER, KEY_ESC, KEY_ENTER,  ];
 
   int  _repeat[4] = [        2,         4,       1,         9,  ];
 
   int  _delay[4]  = [      300,       500,     300,       200,  ];

 
   Execute(_keys, _repeat, _delay, 4);

 
 } else if (process == 2) {
 
   //Execute(bios_sequence, seq_len);   
 
 }

}

void loop() {
 
 // Do nothing after the test

} 


I think I figured it out. The key variables can be ints. Now I can go back to multidimensional arrays. Sorry.


PHP Code

<?php 
const int ledPin = 13;
const 
int hp_bios_key = KEY_F10;
const 
int dell_bios_key = KEY_F2;
const 
int lenovo_bios_key = KEY_F1;

const 
int hp_dell_netboot_key = KEY_F12;
const 
int lenovo_netboot_key = KEY_F3;

void setup() {
 
 pinMode(ledPin, OUTPUT);
 
 for (int i=0; i < 10; i++) {
 
   digitalWrite(ledPin, HIGH);
 
   delay(100);
 
   digitalWrite(ledPin, LOW);
 
   delay(100);
 
 }
 
 //Keyboard.press(KEY_RIGHT);
 
 //delay(250);
 
 //Keyboard.release(KEY_RIGHT);
}

void Execute(int keys[], int repeats[], int delays[], int lens){
 
 int key_to_press;
 
 int key_repeat;
 
 int key_delay;

 
 for (int s = 0; s < lens; s++) {
 
   key_to_press = keys[s];
 
   key_repeat = repeats[s];
 
   key_delay = delays[s];

 
   for (int r = 0; r < key_repeat; r++) {
 
     Keyboard.press(key_to_press);
 
     delay(key_delay);
 
     Keyboard.release(key_to_press);
 
     delay(key_delay / 2);
 
   }
 
 }
}

void HP(byte process) {

 
 if (process == 1) {
 
   int _keys[4]    = { KEY_TAB, KEY_ENTER, KEY_ESC, KEY_ENTER, };
 
   int  _repeat[4] = { 2, 4, 1, 9, };
 
   int  _delay[4]  = { 300, 500, 300, 200, };

 
   Execute(_keys, _repeat, _delay, 4);

 
 } else if (process == 2) {
 
   //Execute(bios_sequence, seq_len);   
 
 }

}

void loop() {
 
 // Do nothing after the test

} 


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersApr 29, 2024 05:37 AM 27 469 Apr 29, 2024 05:37 AM
Last Post: nucleo_type09
[.NET] by MilkMar 13, 2022 03:46 PM 4 133 Mar 13, 2022 03:46 PM
Last Post: #Kat
[Python] by 2xTheTap115May 23, 2020 12:11 PM 5 146 May 23, 2020 12:11 PM
Last Post: Athr