CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
console.c-Dateireferenz
#include "camera_info.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 202 der Datei console.c.

#define MAX_CONSOLE_HISTORY   30

Definiert in Zeile 10 der Datei console.c.

#define MAX_CONSOLE_LINE_LENGTH   44

Definiert in Zeile 11 der Datei console.c.

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

Definiert in Zeile 9 der Datei console.c.

Dokumentation der Funktionen

void console_add_line ( const char *  str)

Definiert in Zeile 109 der Datei console.c.

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

Definiert in Zeile 66 der Datei console.c.

67 {
69 
72 }
void console_close ( )

Definiert in Zeile 60 der Datei console.c.

61 {
64 }
void console_draw ( int  force_redraw)

Definiert in Zeile 74 der Datei console.c.

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

Definiert in Zeile 43 der Datei console.c.

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

Definiert in Zeile 27 der Datei console.c.

28 {
30  console_line_length = line_length;
31  console_y = y_pos;
32  console_x = x_pos;
33 
36 }
static int console_is_inited ( )
static

Definiert in Zeile 38 der Datei console.c.

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

Definiert in Zeile 183 der Datei console.c.

184 {
186  console_displayed = 0;
188 }
void console_set_autoredraw ( int  val)

Definiert in Zeile 178 der Datei console.c.

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

Definiert in Zeile 144 der Datei console.c.

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

Definiert in Zeile 49 der Datei console.c.

50 {
51  // increase line count
54  // move current line and clear content
56  console_cur_line = 0;
58 }
void display_console ( )

Definiert in Zeile 205 der Datei console.c.

206 {
208  console_scroll = 0;
210 }
static void gui_console_draw ( )
static

Definiert in Zeile 213 der Datei console.c.

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

Definiert in Zeile 248 der Datei console.c.

249 {
251  {
252  case JOGDIAL_LEFT:
253  case KEY_UP:
255  {
256  console_scroll++;
258  }
259  break;
260  case JOGDIAL_RIGHT:
261  case KEY_DOWN:
262  if (console_scroll > 0)
263  {
264  console_scroll--;
266  }
267  break;
268  case KEY_SET:
270  break;
271  }
272  return 0;
273 }

Variablen-Dokumentation

int console_autoredraw = 1
static

Definiert in Zeile 23 der Datei console.c.

char console_buf[MAX_CONSOLE_HISTORY][MAX_CONSOLE_LINE_LENGTH+1]
static

Definiert in Zeile 15 der Datei console.c.

int console_cur_line = 0
static

Definiert in Zeile 19 der Datei console.c.

int console_displayed = 0

Definiert in Zeile 25 der Datei console.c.

long console_last_modified
static

Definiert in Zeile 24 der Datei console.c.

int console_line_length = 0
static

Definiert in Zeile 20 der Datei console.c.

int console_max_lines
static

Definiert in Zeile 17 der Datei console.c.

int console_num_lines
static

Definiert in Zeile 18 der Datei console.c.

int console_redraw_flag
static

Definiert in Zeile 199 der Datei console.c.

int console_scroll
static

Definiert in Zeile 200 der Datei console.c.

int console_x
static

Definiert in Zeile 21 der Datei console.c.

int console_y
static

Definiert in Zeile 22 der Datei console.c.

gui_handler* gui_console_mode_old
static

Definiert in Zeile 197 der Datei console.c.

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

Definiert in Zeile 195 der Datei console.c.