Je programme la gestion de la gare sur étagère
http://forum.e-train.fr/viewtopic.php?f=3&t=80622&start=0
Je bute sur l'utilisation de tableau (encore et encore...)
Pour le TCO je déclare ceci :
- Code: Tout sélectionner
PMIO* buttons[][] = {
{
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
NOT_AN_IO
}, {
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
NOT_AN_IO,
NOT_AN_IO
}, {
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
new PMButton(),
NOT_AN_IO
}
}
puis je passe ce tableau à l'objet matrice :
- Code: Tout sélectionner
PMIOMatrix* inputMatrix = new PMInputMatrix(buttons, BUTTON_ROW_COUNT, buttonsPins);
enfin je l'utilise de cette manière :
- Code: Tout sélectionner
void PMIOMatrix::doForThis() {
//send clear
digitalWrite(this->pins[PIN_CLEAR], LOW);
digitalWrite(this->pins[PIN_CLEAR], HIGH);
for (unsigned char r = 0; r < this->rowCount; r++) {
digitalWrite(this->pins[PIN_ROW_DATA], r == 0 ? HIGH : LOW);
digitalWrite(this->pins[PIN_ROW_CLOCK], HIGH);
digitalWrite(this->pins[PIN_ROW_CLOCK], LOW);
digitalWrite(this->pins[PIN_ROW_STORE], HIGH);
digitalWrite(this->pins[PIN_ROW_STORE], LOW);
digitalWrite(this->pins[PIN_COL_STORE], HIGH);
digitalWrite(this->pins[PIN_COL_STORE], LOW);
for (unsigned char c = 0; c < MATRIX_COL_COUNT; c++) {
if (this->io[r][c] != NOT_AN_IO) {
digitalWrite(this->pins[PIN_COL_CLOCK], HIGH);
digitalWrite(this->pins[PIN_COL_CLOCK], LOW);
this->io[r][c]->setValue(digitalRead(this->pins[PIN_COL_DATA]));
}
}
}
}
Le compilateur Arduino renvoi comme erreur
- Code: Tout sélectionner
PMInputMatrix.cpp:33: error: no match for 'operator[]' (operand types are 'PMIO' and 'unsigned char')
if (this->io[r][c] != NOT_AN_IO) {
En théorie this->io == buttons. Je ne comprends donc pas pourquoi je ne peut pas accéder au données du tableau.
Please, help me !