Liste durchscrollen

Gast #4961380
Lesenswert?

Hallo,
Ich versuche ein Array auszugeben mit 49 Einträgen, das wollte ich 
mittels slider zum Scrollen machen.
Nur leider werden mir nur die ersten 17 Einträge angezeigt.
Vielleicht könnte mir da einer Weiterhelfen
1
void scroll_list_vertical(void)
2
{  
3
    if( touch_type == RESISTIVE_TOUCH )
4
    {
5
      getDisplayPoint(&display, Read_Value(), &matrix ) ;
6
       
7
//###################################################################################      
8
      //SLIDER
9
        if ((display.x>102+400) && (display.x<123+400))
10
         {
11
           
12
          if ((display.y>102) && (display.y<398))  
13
            {
14
             up_down = display.y;
15
             Draw_Rectangle(100+400,100,125+400,400,LCD_COLOR_BLUE,LCD_COLOR_RED);
16
  
17
             //Slider
18
             Draw_Rectangle(102+400,display.y,123+400,display.y+5,LCD_COLOR_RED,LCD_COLOR_YELLOW);            
19

20
             scroll_list_vertical_text_plus(display.y);
21
           }
22
        }   
23
  //oben
24
        if ((display.x>102+400) && (display.x<123+400))
25
         {
26
           
27
          if ((display.y>80) && (display.y<100))  
28
            {
29
           
30
          if (up_down > 99)  
31
            { up_down --;
32
            
33
             Draw_Rectangle(100+400,100,125+400,400,LCD_COLOR_BLUE,LCD_COLOR_RED);
34
  
35
             //Slider
36
             Draw_Rectangle(102+400,up_down,123+400,up_down+5,LCD_COLOR_RED,LCD_COLOR_YELLOW);            
37

38
             scroll_list_vertical_text_plus(up_down);
39
           }
40

41
           
42
          } 
43
        }
44

45
//unten
46
        if ((display.x>102+400) && (display.x<123+400))
47
         {
48
           
49
          if ((display.y>402) && (display.y<422))  
50
            {
51
            
52
             
53
           if (up_down < 398)  
54
            {  
55
             up_down ++;
56

57
             Draw_Rectangle(100+400,100,125+400,400,LCD_COLOR_BLUE,LCD_COLOR_RED);
58
  
59
             //Slider
60
             Draw_Rectangle(102+400,up_down,123+400,up_down+5,LCD_COLOR_RED,LCD_COLOR_YELLOW);            
61

62
             scroll_list_vertical_text_minu(up_down);
63
           }  
64
             
65
          }
66
        }           
67
           
68
           
69
           
70
           
71
            
72
    }
73
  }
74

75
  
76
void scroll_list_vertical_text_minu(int y)
77
{  
78
  char    acText[50] ;
79
  
80
  u16 i, j , k,h,p;
81

82
  if ((y>102) && (y<398-16))  
83
   {  
84
     j = 49-((y-102)*49/(398-16));
85
        
86

87
       for( k=48; k>1; k-- )
88
         {
89
          h = (k*16)+y; 
90
           
91
           
92
           if (h<398-16)
93
            {           
94
             sprintf( acText,"MINUS:%d" ,k  ); 
95
             GUI_Text( 105, h, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);         
96
       }
97
   
98
         }
99

100

101
         
102
    }
103
}  
104

105

106
void  scroll_list_vertical_text_plus(int y)
107
{  
108
  char    acText[50] ;
109
  
110
  u16 i, j , k,h,p;
111

112
  if ((y>102) && (y<398-16))  
113
   {  
114
     j = 49+((y-102)*49/(398-16));
115
        
116

117
       for( k=0; k<25; k++ )
118
         {
119
           h = (k*16)+y; 
120
           
121
     
122
             if (h<398-16)
123
             {
124
              sprintf( acText,"PLUSS:%d" ,k  ); 
125
              GUI_Text( 105, h, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);
126
             }           
127
         }        
128
            
129
           
130
    }
131
  }
Gast #4961451
Lesenswert?

Lothar M. schrieb:
> andy schrieb:
>> Ich versuche ein Array auszugeben mit 49 Einträgen
> Worauf?
       for( k=0; k<49; k++ )
         {
           h = (k*16)+y;


             if (h<398-16)
             {
              sprintf( acText,"PLUSS:%d" ,k  );
              GUI_Text( 105, h, acText, LCD_COLOR_WHITE, 
LCD_COLOR_BLUE);
             }
         }

Mein Ausdruck war vermutlich nicht richtig gewählt.

Ich habe ein Fenster 300x300 Pixel.
Die erste Ausgabezeile beginnt bei x105 y105.

In das Fenster Passen ja nur 18 Einträge in Y-Rchtung.

Ich wollte wenn die ersten 18 Einträge im Fenster erscheinen durch die 
Slider Position die nächsten Einträge erscheinen.
Moderator (Firma: Titel) Persönliche Seite #4961470
Lesenswert?

andy schrieb:
> Ich wollte wenn die ersten 18 Einträge im Fenster erscheinen durch die
> Slider Position die nächsten Einträge erscheinen.
Dir ist aber schon klar, dass die ausgegebenen Texte nicht mit der 
Position zu tun haben, weil k einfach nur von der for-Schleife abhängt. 
Du rechnest da zwar irgendein j mit der y-Position aus, verwendest es 
aber nicht weiter...

Ich würde sowieso die darzustellende Liste von der Darstellung selber 
entkoppeln, nur einen Pointer auf das erste Element berechnen und den 
dann einer Funktion übergeben, die ab dort 18 Zeilen ausgibt.
Gast #4961479
Lesenswert?

Mach mal aus den vielen Konstanten, "lesbare" Werte.

Übrigens: In vielen Fällen kann man in einem Fenster, das 17 Zeilen 
umfasst, auch 70 Zeilen ausgeben. Nur sieht man sie nicht! Das ist wie 
Deine hübsche Nachbarin hinter dem Fenster, auch wenn man das 
Fahrgestell von außen nicht sieht, so ist es doch vorhanden!
Gast #4961682
Lesenswert?

Lothar M. schrieb:
>
> Ich würde sowieso die darzustellende Liste von der Darstellung selber
> entkoppeln, nur einen Pointer auf das erste Element berechnen und den
> dann einer Funktion übergeben, die ab dort 18 Zeilen ausgibt.

ich hab das jetzt mal so umgesetzt, sicherlich ist das jetzt nicht die 
Sinnvollste Lösung.

Gibt es ein Beispiel wie man dies mit Pointern macht.




  g = 0;  //1. Seite
  scroll_list_vertical_text_one(105);

        g = 1;  //2. Seite
  scroll_list_vertical_text_one(105);

        g = 2;  //3. Seite
  scroll_list_vertical_text_one(105);


1
u16 g = 0;
2

3

4

5
void scroll_list_vertical(void)
6
{  
7
    if( touch_type == RESISTIVE_TOUCH )
8
    {
9
      getDisplayPoint(&display, Read_Value(), &matrix ) ;
10
       
11
//###################################################################################      
12
      //SLIDER
13
        if ((display.x>102+400) && (display.x<123+400))
14
         {
15
           
16
          if ((display.y>102) && (display.y<398))  
17
            {
18
             up_down = display.y;
19
             Draw_Rectangle(100+400,100,125+400,400,LCD_COLOR_BLUE,LCD_COLOR_RED);
20
  
21
             //Slider
22
             Draw_Rectangle(102+400,display.y,123+400,display.y+5,LCD_COLOR_RED,LCD_COLOR_YELLOW);            
23

24
             scroll_list_vertical_text_plus(display.y);
25
           }
26
        }   
27
  //oben
28
        if ((display.x>102+400) && (display.x<123+400))
29
         {
30
           
31
          if ((display.y>80) && (display.y<100))  
32
            {
33
           
34
          if (up_down > 99)  
35
            { 
36
             Delay(100);
37
             up_down --;
38
            
39
             Draw_Rectangle(100+400,100,125+400,400,LCD_COLOR_BLUE,LCD_COLOR_RED);
40
  
41
             //Slider
42
             Draw_Rectangle(102+400,up_down,123+400,up_down+5,LCD_COLOR_RED,LCD_COLOR_YELLOW);            
43

44
             scroll_list_vertical_text_one(up_down);
45
             g ++;
46
           }
47
           
48
          } 
49
        }
50

51
//unten
52
        if ((display.x>102+400) && (display.x<123+400))
53
         {
54
           
55
          if ((display.y>402) && (display.y<422))  
56
            {
57
            
58
             
59
           if (up_down < 398)  
60
            {  
61
           
62
              if (g > 0)  
63
               {  g --;           
64
               Delay(100);
65
               up_down ++;
66

67
               Draw_Rectangle(100+400,100,125+400,400,LCD_COLOR_BLUE,LCD_COLOR_RED);
68
  
69
               //Slider
70
               Draw_Rectangle(102+400,up_down,123+400,up_down+5,LCD_COLOR_RED,LCD_COLOR_YELLOW);            
71

72
               scroll_list_vertical_text_one(up_down);
73
             
74
            }   
75
             
76
             
77
           }  
78
             
79
          }
80
        }             
81
    }
82
  }
83

84

85

86
void  scroll_list_vertical_text_one(int y)
87
{  
88
  char    acText[50] ;
89
  
90
  u16 k,h;
91
    
92
     sprintf( acText,"item:%d" ,g  ); 
93
     GUI_Text( 105, 0, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);        
94

95
       for( k=0; k<17; k++ )
96
         {
97
           h = (k*16)+105; 
98
           
99
     
100
            if (g == 0)
101
            {
102

103
             if (h<398-16)
104
              {
105
               sprintf( acText,"PLUSS.:%d " ,k  ); 
106
               GUI_Text( 105, h, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);
107
               Delay(50);
108
              }  
109
            }  
110
            
111
            if (g == 1)
112
             {
113
               if (h<398-16)
114
                {
115
                 sprintf( acText,"PLUSS.:%d " ,k+17  ); 
116
                 GUI_Text( 105, h, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);
117
                 Delay(50);
118
                }
119
             }
120
            if (g == 2)
121
             {
122
               if (h<398-16)
123
                {
124
                 sprintf( acText,"PLUSS.:%d " ,k+34  ); 
125
                 GUI_Text( 105, h, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);
126
                 Delay(50);
127
                }
128
             }
129

130
            if (g == 3)
131
             {
132
               if (h<398-16)
133
                {
134
                 sprintf( acText,"PLUSS.:%d " ,k+50  ); 
135
                 GUI_Text( 105, h, acText, LCD_COLOR_WHITE, LCD_COLOR_BLUE);
136
                 Delay(50);
137
                }
138
             }
139
         }
140
  }

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