probleme mit "0" und strings/arrays

OP #1422897
Lesenswert?

1
void sendCmd(uint8_t cmdindex, uint8_t *param)
2
{
3
  char dsplout[MAXLEN];
4
  uint32_t chksum = 0;
5
  uint8_t index = 0;
6
  uint8_t len = 3;
7
  chksum = 0;
8
  
9
  dsplout[index] = DC1;
10
  chksum = chksum + dsplout[index++];
11
  dsplout[++index] = ESC;
12
  chksum = chksum + dsplout[index];
13
  dsplout[++index] =commands[cmdindex][0];
14
  chksum = chksum + dsplout[index];
15
  dsplout[++index] =commands[cmdindex][1];
16
  chksum = chksum + dsplout[index];
17

18
  while(*param)
19
  {
20
    dsplout[++index] = *param++;
21
    chksum = chksum + dsplout[index];
22
    len++;
23
    PORTB |= (1<<PB6);
24
    _delay_ms(20);
25
    PORTB &= ~(1<<PB6);
26
    _delay_ms(20);
27
  }
28
  chksum = chksum + len;
29
  chksum = chksum % 256;
30
  dsplout[1] = len;
31
  //dsplout[6] = '3';
32
  dsplout[++index] = chksum;
33
  dsplout[++index] = '\0';
34
  sendChar(dsplout);
35
}
36

37
void setPicture(char num, uint16_t xpos, uint16_t ypos)
38
{
39
   uint8_t val[5];
40
   val[0] = 1;//xposlbyte
41
   val[1] = 0;//xposhbyte
42
   val[2] = 1;//yposlbyte
43
   val[3] = 0;//yposhbyte
44
   val[4] = 1;
45

46
   sendCmd(CMD_SETPICTURE, val, sizeof(val));
47
}

Hi....
Ich habe volgendes problem ich will mit der funktion setPicture nullen 
an die Funktion sendCmd schicken,wie im code beschrieben... ich habe 
leider keine ahnung wie mir das möglich sein könnte...

währe für jede hilfe sehr dankbar !!!

MFG mcmorf....
Gast #1422915
Lesenswert?

Benjamin A. schrieb:

> Ich habe volgendes problem ich will mit der funktion setPicture nullen
> an die Funktion sendCmd schicken,wie im code beschrieben...

Im Code ist gar nichts beschrieben, das ist schon mal der erste Fehler.

Die Variablen sind groesstenteils unleserlich, Fehler Nummer 2.

Du gibst keiner Informationen darueber, um was fuer eine Hardware es 
sich handelt: Fehler 3.

Du rufst eine Funktion sendCmd mit 3 Parametern auf, die nur 2 annimmt: 
Fehler 4.

Ach so, welcher Fehler auftritt, schreibst du auch nicht: Fehler 5.

Also, eventuell hilft es, wenn du die Werte als ASCII sendest und dir 
ein C-Buch kaufst.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren