SayoriOS  0.3.3
bootscreen.c
См. документацию.
1 
9 #include <version.h>
10 #include <io/ports.h>
11 #include "io/tty.h"
12 
13 uint32_t theme = 0;
14 uint32_t bgColorDark = 0x000000;
15 uint32_t txColorDark = 0x92D7D4;
16 uint32_t bgColorLight = 0xD6D2D0;
17 uint32_t txColorLight = 0x2D3C5D;
18 uint32_t maxStrLine = 0;
19 uint32_t maxHeightLine = 0;
20 bool lazy = false;
21 uint32_t curElem = 0;
22 uint32_t maxElem = 10;
23 uint32_t mode = 0;
24 bool bs_logs = true;
25 
31 void bootScreenLazy(bool l){
32  lazy = l;
33 }
34 
40 void bootScreenChangeTheme(uint32_t th){
41  theme = th;
42 }
43 
49 uint32_t bootScreenTheme(uint32_t type){
50  uint32_t map[2][3] = {
51  {txColorDark, bgColorDark, 0x262626},
52  {txColorLight, bgColorLight, 0x262626}
53  };
54 
55  if(theme >= 2 || type >= 3) {
56  return txColorDark;
57  }
58 
59  return map[theme][type];
60 
61 // if (theme == 0 && type == 0) {
62 // return txColorDark;
63 // } else if (theme == 0 && type == 1){
64 // return bgColorDark;
65 // } else if (theme == 0 && type == 2){
66 // return 0x262626;
67 // } else if (theme == 1 && type == 0){
68 // return txColorLight;
69 // } else if (theme == 1 && type == 1){
70 // return bgColorLight;
71 // } else if (theme == 1 && type == 2){
72 // return 0x262626;
73 // } else {
74 // return txColorDark;
75 // }
76 }
77 
84 void bootScreenClose(uint32_t bg, uint32_t tx){
85  tty_setcolor(tx);
86  drawRect(0, 0, getScreenWidth(), getScreenHeight(), bg);
87  setPosX(0);
88  setPosY(0);
89  tty_changeState(true);
90 }
91 
98  mode = m;
99 }
100 
105  setPosX(0);
106  setPosY(0);
107  if (!lazy){
108  tty_printf("SayoriOS v%d.%d.%d\nBuilt: %s\n",
109  VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, // Версия ядра
110  __TIMESTAMP__ // Время окончания компиляции ядра
111  );
112 
113  char* about = "(c) SayoriOS Team";
114  uint32_t centerAbout = (maxStrLine/2)-(strlen(about)/2);
115 
118  setPosX(((1+centerAbout)*8));
119  setPosY(getScreenHeight() - 32);
120  tty_printf(about);
121  }
122  setPosX(0);
123  setPosY(16*5);
124 
125 
126 }
127 
132  curElem++;
133  if (curElem >= maxElem){
134  curElem = maxElem;
135  }
136  uint32_t padding_h = maxHeightLine/4;
137  uint32_t proc = (curElem*100)/maxElem;
138  //qemu_log("[BS] Proc: %d | C: %d | E: %d",proc,curElem,maxElem);
139  //setPosX(8*8);
140 
141  drawRect(8*8,(16*((maxHeightLine-padding_h+2))),(proc)*7,16,bootScreenTheme(0));
142 }
143 
149 void bootScreenPaint(char* title){
150  if (bs_logs)
151  qemu_log("[BOOT] %s",title);
152 
153  if (mode == 1){
154  tty_changeState(true);
157  tty_printf("%s\n",title);
158  tty_changeState(false);
159  punch();
160  return;
161  }
162 
163  maxStrLine = (getScreenWidth() / 8) - 2;
164  maxHeightLine = getScreenHeight() / 16;
165 
168  tty_changeState(true);
169 
170  uint32_t centerTitle = (maxStrLine/2) - (mb_strlen(title)/2);
171  uint32_t padding_h = maxHeightLine/4;
172 
173  // punch();
174  if (lazy){
175  drawRect(0,16*((maxHeightLine-padding_h)), getScreenWidth(), 16, bootScreenTheme(1));
176  } else {
177  drawRect(0, 0, getScreenWidth(), getScreenHeight(), bootScreenTheme(1));
178  }
179  // punch();
180  setPosX(((1+centerTitle)*8));
181  setPosY(16*((maxHeightLine-padding_h)));
182  tty_printf(title);
183  bootScreenInfo();
185  tty_changeState(false);
186 
187  punch();
188 }
189 
195 void bootScreenInit(uint32_t count){
196  // Предварительная настройка BootScreen
197  maxElem = count;
198  if (bs_logs) qemu_log("Init...");
199  tty_changeState(false); // Disabling print functions
200  maxStrLine = (getScreenWidth() / 8) - 2;
201  maxHeightLine = getScreenHeight() / 16;
202  bootScreenPaint("Загрузка...");
203 
204 }
uint32_t theme
Текущая тема (0 или 1)
Definition: bootscreen.c:13
uint32_t maxStrLine
Максимальное количество символом на строку
Definition: bootscreen.c:18
void bootScreenInfo()
Выводит во время загрузки служебную информацию BootScreen.
Definition: bootscreen.c:104
void bootScreenPaint(char *title)
Обновить информацию для BootScreen.
Definition: bootscreen.c:149
uint32_t bootScreenTheme(uint32_t type)
Возращает цвет оформления
Definition: bootscreen.c:49
uint32_t mode
Режим работы (0 - Обычный | 1 - Режим логирования)
Definition: bootscreen.c:23
uint32_t bgColorLight
Цвет заднего фона для светлой темы
Definition: bootscreen.c:16
void bootScreenInit(uint32_t count)
Инициализирует BootScreen.
Definition: bootscreen.c:195
bool bs_logs
Включено ли логгирование этапов BootScreen.
Definition: bootscreen.c:24
uint32_t bgColorDark
Цвет заднего фона для темной темы
Definition: bootscreen.c:14
void bootScreenChangeTheme(uint32_t th)
Сменить тему BootScreen.
Definition: bootscreen.c:40
uint32_t maxElem
Максимальное позиция элемента
Definition: bootscreen.c:22
uint32_t maxHeightLine
Максимальное количество строк на экране
Definition: bootscreen.c:19
uint32_t txColorLight
Цвет текста для светлой темы
Definition: bootscreen.c:17
bool lazy
Ленивая прорисовка
Definition: bootscreen.c:20
uint32_t txColorDark
Цвет текста для темной темы
Definition: bootscreen.c:15
void bootScreenClose(uint32_t bg, uint32_t tx)
Завершает работу BootScreen.
Definition: bootscreen.c:84
void bootScreenChangeMode(int m)
Смена режима отображения BootScreen.
Definition: bootscreen.c:97
uint32_t curElem
Текущая позиция элемента
Definition: bootscreen.c:21
void bootScreenLazy(bool l)
Включить ленивую загрузку для BootScreen.
Definition: bootscreen.c:31
void bootScreenProcentPaint()
Рисует прогресс-бар для BootScreen.
Definition: bootscreen.c:131
size_t strlen(const char *str)
Возращает длину строки
Definition: string.c:88
size_t mb_strlen(const char *str)
Возращает длину строки с учетом UTF-8.
Definition: string.c:107
void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color)
Рисуем залитый прямоугольник
Definition: pixel.c:25
void setPosX(uint32_t x)
Изменяем позицию курсора по X.
Definition: tty.c:154
void tty_changeState(bool state)
Меняет состояние печати через printf.
Definition: tty.c:76
void setPosY(uint32_t y)
Изменяем позицию курсора по Y.
Definition: tty.c:164
void tty_set_bgcolor(uint32_t color)
Изменение цвета заднего фона
Definition: tty.c:121
void tty_setcolor(uint32_t color)
Изменение цвета текста
Definition: tty.c:108