+
+static void rec_menu(Bitmap *bm)
+{
+ gfx_bitmapClear(bm);
+ text_style(bm, STYLEF_BOLD | STYLEF_UNDERLINE, STYLEF_BOLD | STYLEF_UNDERLINE);
+ text_xprintf(bm, 0, 0, TEXT_CENTER | TEXT_FILL, "Microphone recorder.");
+ text_style(bm, 0, STYLEF_MASK);
+ text_xprintf(bm, 2, 0, TEXT_NORMAL, "Press RIGHT button to start recording");
+ text_xprintf(bm, 3, 0, TEXT_NORMAL, "and to stop it re-press RIGHT button.");
+ lcd_hx8347_blitBitmap(bm);
+
+ ticks_t start= 0;
+ while (1)
+ {
+ keymask_t key = kbd_peek();
+ if (key & K_LEFT)
+ {
+ break;
+ }
+ if (key & K_RIGHT)
+ {
+ char file_name[13];
+ memset(file_name, 0, sizeof(file_name));
+ sprintf(file_name, "REC%d.WAV", recorderd_file_idx);
+ kprintf("rec %s\n", file_name);
+
+ if (!is_recording)
+ {
+ start_rec(file_name);
+ text_xprintf(bm, 5, 0, TEXT_CENTER | TEXT_FILL, "Start recording on file: %s", file_name);
+ lcd_hx8347_blitBitmap(bm);
+ start = timer_clock();
+ }
+ else
+ {
+ stop_rec();
+ recorderd_file_idx++;
+ text_xprintf(bm, 5, 0, TEXT_CENTER | TEXT_FILL, "Stop recording: %s", file_name);
+ mtime_t elaps = ticks_to_ms(timer_clock() - start);
+ text_xprintf(bm, 6, 0, TEXT_CENTER | TEXT_FILL, "Recorded: %ld.%ldsec", elaps / 1000, elaps % 1000);
+ lcd_hx8347_blitBitmap(bm);
+ }
+ }
+
+ cpu_relax();
+ }
+}
+
+
+