CHDK_DE Vorschauversion  Trunk Rev. 5218
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
console.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.h"
#include "conf.h"
#include "console.h"
#include "clock.h"
#include "keyboard.h"
#include "gui.h"
#include "gui_draw.h"
+ Include-Abhängigkeitsdiagramm für console.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define MAX_CONSOLE_LINES   (camera_screen.height/FONT_HEIGHT-1)
 
#define MAX_CONSOLE_HISTORY   30
 
#define MAX_CONSOLE_LINE_LENGTH   44
 
#define MAX_CONSOLE_DISP_LINES   12
 

Funktionen

static void console_init (int num_lines, int line_length, int x_pos, int y_pos)
 
static int console_is_inited ()
 
static void console_ensure_inited ()
 
static void console_start_line ()
 
void console_close ()
 
void console_clear ()
 
void console_draw (int force_redraw)
 
void console_add_line (const char *str)
 
void console_set_layout (int x1, int y1, int x2, int y2)
 
void console_set_autoredraw (int val)
 
void console_redraw ()
 
static void gui_console_draw ()
 
static int gui_console_kbd_process ()
 
void display_console ()
 

Variablen

static char console_buf [MAX_CONSOLE_HISTORY][MAX_CONSOLE_LINE_LENGTH+1]
 
static int console_max_lines
 
static int console_num_lines
 
static int console_cur_line = 0
 
static int console_line_length = 0
 
static int console_x
 
static int console_y
 
static int console_autoredraw = 1
 
static long console_last_modified
 
int console_displayed = 0
 
static gui_handler mboxGuiHandler = { GUI_MODE_MBOX, gui_console_draw, gui_console_kbd_process, 0, 0, 0 }
 
static gui_handlergui_console_mode_old
 
static int console_redraw_flag
 
static int console_scroll
 

Makro-Dokumentation

#define MAX_CONSOLE_DISP_LINES   12

Definiert in Zeile 203 der Datei console.c.

#define MAX_CONSOLE_HISTORY   30

Definiert in Zeile 11 der Datei console.c.

#define MAX_CONSOLE_LINE_LENGTH   44

Definiert in Zeile 12 der Datei console.c.

#define MAX_CONSOLE_LINES   (camera_screen.height/FONT_HEIGHT-1)

Definiert in Zeile 10 der Datei console.c.

Dokumentation der Funktionen

void console_add_line ( const char *  str)

Definiert in Zeile 110 der Datei console.c.

111 {
112  // Set console_autoredraw to -1 to stop script print statements from being displayed on screen
113  // Can be used to send script output to a file (using print_screen function); but not have it displayed
114  // on the LCD.
115  if (console_autoredraw == -1)
116  return;
117 
120 
121  do
122  {
123  char *cur = console_buf[console_cur_line];
124  int curlen = strlen(cur);
125  int left = console_line_length - curlen;
126  if (strlen(str) > left)
127  {
128  strncpy(cur + curlen, str, left);
129  cur[console_line_length] = 0;
131  str += left;
132  }
133  else
134  {
135  strcat(cur, str);
136  break;
137  }
138  } while(1);
139 
140  // ToDo: this should probably only be done if console_autoredraw == 0; but that breaks existing scripts (e.g. EDI.lua)
141  console_displayed = 0;
143 }
void console_clear ( )

Definiert in Zeile 67 der Datei console.c.

68 {
70 
73 }
void console_close ( )

Definiert in Zeile 61 der Datei console.c.

62 {
65 }
void console_draw ( int  force_redraw)

Definiert in Zeile 75 der Datei console.c.

76 {
78 
80 
82 
83  long t = get_tick_count();
84  if (t <= console_last_modified + (conf.console_timeout*1000)) // Redraw if changed
85  {
86  if ((console_displayed == 0) || force_redraw)
87  {
88  int y = (console_y + console_max_lines - 1) * FONT_HEIGHT;
90 
91  int c, i;
92  for (c = 0, i = console_cur_line; c < console_num_lines; ++c, --i)
93  {
94  if (i < 0) i = MAX_CONSOLE_HISTORY-1;
96  buf[console_line_length] = 0;
98 
100  }
101  }
102  }
103  else if (console_displayed && !camera_info.state.state_kbd_script_run) // Erase if drawn and script not running
104  {
106  console_displayed = 0;
107  }
108 }
static void console_ensure_inited ( )
static

Definiert in Zeile 44 der Datei console.c.

45 {
46  if (!console_is_inited())
47  console_init(5, 25, 0, MAX_CONSOLE_LINES - 5);
48 }
static void console_init ( int  num_lines,
int  line_length,
int  x_pos,
int  y_pos 
)
static

Definiert in Zeile 28 der Datei console.c.

29 {
31  console_line_length = line_length;
32  console_y = y_pos;
33  console_x = x_pos;
34 
37 }
static int console_is_inited ( )
static

Definiert in Zeile 39 der Datei console.c.

40 {
41  return (console_line_length > 0);
42 }
void console_redraw ( )

Definiert in Zeile 184 der Datei console.c.

185 {
187  console_displayed = 0;
189 }
void console_set_autoredraw ( int  val)

Definiert in Zeile 179 der Datei console.c.

180 {
181  console_autoredraw = val;
182 }
void console_set_layout ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definiert in Zeile 145 der Datei console.c.

146 {
147  int i;
148 
149  // Swap co-ords so x1 < x2 & y1 < y2
150  if (x1 > x2) { i = x1; x1 = x2; x2 = i; }
151  if (y1 > y2) { i = y1; y1 = y2; y2 = i; }
152 
153  // Limit values to screen range (TODO: add error message if out of range)
154  if (x1 < 0) x1 = 0;
156  if (x2 < 0) x2 = 0;
158 
159  if (y1 < 0) y1 = 0;
160  if (y1 > MAX_CONSOLE_LINES) y1 = MAX_CONSOLE_LINES;
161  if (y2 < 0) y2 = 0;
162  if (y2 > MAX_CONSOLE_LINES) y2 = MAX_CONSOLE_LINES;
163 
164  //Adjust for new size if needed
165  console_line_length = x2 - x1;
166  console_max_lines = y2 - y1;
167 
168  // If number of lines in console has reduced and old console has too many lines
171 
172  console_x = x1;
174 
175  if (console_autoredraw)
176  console_redraw();
177 }
static void console_start_line ( )
static

Definiert in Zeile 50 der Datei console.c.

51 {
52  // increase line count
55  // move current line and clear content
57  console_cur_line = 0;
59 }
void display_console ( )

Definiert in Zeile 206 der Datei console.c.

207 {
209  console_scroll = 0;
211 }
static void gui_console_draw ( )
static

Definiert in Zeile 214 der Datei console.c.

215 {
217  {
219 
222 
223  coord x = (camera_screen.width - w * FONT_WIDTH) >> 1;
224  coord y = (camera_screen.height - (h+1) * FONT_HEIGHT) >> 1;
225 
226  draw_rectangle(x-3, y-3, x+w*FONT_WIDTH+3, y+(h+1)*FONT_HEIGHT+2, col, RECT_BORDER1|DRAW_FILLED); // main box
227  draw_rectangle(x-2, y-2, x+w*FONT_WIDTH+2, y+FONT_HEIGHT+1, col, RECT_BORDER1|DRAW_FILLED); //title
228 
229  draw_string_justified(x, y, "Console - press SET to close", col, 0, w*FONT_WIDTH, TEXT_CENTER); //title text
230  y += FONT_HEIGHT + 2;
231 
232  int c, i;
233  for (c = h-1, i = console_cur_line-console_scroll; c >= 0; --c, --i)
234  {
235  if (i < 0) i += MAX_CONSOLE_HISTORY;
237  }
238 
239  // Scrollbar
241  x+w*FONT_WIDTH+2, y+((MAX_CONSOLE_HISTORY-console_scroll)*(h*FONT_HEIGHT))/MAX_CONSOLE_HISTORY-1,
243 
245  }
246 }
static int gui_console_kbd_process ( )
static

Definiert in Zeile 249 der Datei console.c.

250 {
252  {
253  case JOGDIAL_LEFT:
254  case KEY_UP:
256  {
257  console_scroll++;
259  }
260  break;
261  case JOGDIAL_RIGHT:
262  case KEY_DOWN:
263  if (console_scroll > 0)
264  {
265  console_scroll--;
267  }
268  break;
269  case KEY_SET:
271  break;
272  }
273  return 0;
274 }

Variablen-Dokumentation

int console_autoredraw = 1
static

Definiert in Zeile 24 der Datei console.c.

char console_buf[MAX_CONSOLE_HISTORY][MAX_CONSOLE_LINE_LENGTH+1]
static

Definiert in Zeile 16 der Datei console.c.

int console_cur_line = 0
static

Definiert in Zeile 20 der Datei console.c.

int console_displayed = 0

Definiert in Zeile 26 der Datei console.c.

long console_last_modified
static

Definiert in Zeile 25 der Datei console.c.

int console_line_length = 0
static

Definiert in Zeile 21 der Datei console.c.

int console_max_lines
static

Definiert in Zeile 18 der Datei console.c.

int console_num_lines
static

Definiert in Zeile 19 der Datei console.c.

int console_redraw_flag
static

Definiert in Zeile 200 der Datei console.c.

int console_scroll
static

Definiert in Zeile 201 der Datei console.c.

int console_x
static

Definiert in Zeile 22 der Datei console.c.

int console_y
static

Definiert in Zeile 23 der Datei console.c.

gui_handler* gui_console_mode_old
static

Definiert in Zeile 198 der Datei console.c.

gui_handler mboxGuiHandler = { GUI_MODE_MBOX, gui_console_draw, gui_console_kbd_process, 0, 0, 0 }
static

Definiert in Zeile 196 der Datei console.c.