;	 Hlavicka
; show_buffer_is_busy
; show_stop
; show_periodic_sampling
; show_X_sync
; show_coupling
; show_trigger_single_mode

; Show_time_base
; Show_voltage_range

; Show_samples_results - Zobrazi Vpp, periodu, frekvenci atd...
  ; Vyuziva nize uvedene podprogramy. Neprovadi samotny vypocet. Pouze
  ; zobrazuje vysledky. Vypocty zajistuje "Samples_calc"
; Show_Vpp	; napeti spicka-spicka
; Show_T	; perioda
; Load_range_LSB_to_Z	; Do ukazatele Z ulozi hodnotu LSB bitu. Od teto
  ; reference se vypocitava zmerene napeti
; Load_time_base_LSB_to_Z	;  Do ukazatele Z ulozi hodnotu jednoho bitu
  ; v case (casova jednotka pro jeden px)


; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
show_buffer_is_busy:	; Zobrazi takove cerne "B" vlevo nahore
	LDI data,OSC_info_symbols_line
	RCALL select_line_right	; Vybereme 1. radek (uplne nahore)
	LDI data,36
	RCALL select_X_right	; a zvolime Xovou souradnici

;	LDI data,0b01111111
;	RCALL write_right
  ; A takhle uz vypada pismeno "B" v binarnim kodu
	LDI data,0b01000001
	RCALL write_right
	LDI data,0b01010101
	RCALL write_right
	LDI data,0b01101011
	RCALL write_right
	LDI data,0b01111111
	RCALL write_right

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
show_stop:	; zobrazi informaci, ze jsme v modu "Stop" -> "S"
	LDI data,OSC_info_symbols_line
	RCALL select_line_right
	LDI data,36
	RCALL select_X_right

	LDI data,0b01011011
	RCALL write_right
	LDI data,0b01010101
	RCALL write_right
	LDI data,0b01101101
	RCALL write_right
	LDI data,0b01111111
	RCALL write_right

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
show_periodic_sampling:	; Zobrazi cerne "P" vlevo nahore
	LDI data,OSC_info_symbols_line
	RCALL select_line_right
	LDI data,40
	RCALL select_X_right

  ; Takhle vypada pismeno "P" v binarnim kodu
	LDI data,0b01111111
	RCALL write_right
	LDI data,0b01000001
	RCALL write_right
	LDI data,0b01110101
	RCALL write_right
	LDI data,0b01111011
	RCALL write_right
	LDI data,0b01111111
	RCALL write_right

  ; A jeste zjistime, jestli se nejedna o zoom 2x, nebo 5x
	CPI number,207	; test na zoom 5x
	BREQ show_zoom_5x	; pokud se jedna o 207 -> skok na show_zoom_5x
  ; a to same pro 208
	CPI number,208
	BREQ show_zoom_2x

	RET	; pokud se nejednalo ani o 207 a 208, nemusime dal nic resit

show_zoom_5x:
	LDI data,0b01011001
	RCALL write_right
	LDI data,0b01010101
	RCALL write_right
	LDI data,0b01101101
	RCALL write_right
	RJMP show_zoom_end	; konec je pro oba pripady stejny. Zbytecne
  ; psat 2x. Sice prijdeme o 2 takty, ale tady je to opravdu zanedbatelny cas

show_zoom_2x:
	LDI data,0b01001101
	RCALL write_right
	LDI data,0b01010101
	RCALL write_right
	LDI data,0b01011011
	RCALL write_right
show_zoom_end:
;	LDI data,0b01111111
;	RCALL write_right	; neni potreba vykreslovat. Vykresli se vzdy,
  ; protoze vzdycky bude zapla nejaka synchrnonizace
	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
show_X_sync:

	LDI data,OSC_info_symbols_line
	RCALL select_line_right
	LDI data,48
	RCALL select_X_right

  ; Nyni se zapisi data na LCD
	LDI data,0b01111111
	RCALL write_right
  ; Tohle bylo spolecne pro oba znaky. Ted se musime rozhodnout jestli se
  ; vykresli znak "I", nebo "E" a nebo "C" (kontinualne se vzorkuje)
	LDS tmp,trigger_mode_SRAM
	CPI tmp,2	; Porovname s hodnotou 2 (kontinualni mod)
	BREQ show_no_sync	; Pokud zde bude shoda, pak se vypise "C"

	LDS tmp,trigger_INT_EXT_SRAM	; stahneme si informaci do registru
  ; "tmp"
	SBRC tmp,0	; a kontrola LSB. Pokud bude LSB=0 -> pokracuje na
  ; show_internal_sync. V opacnem pripade show_external_sync
	RJMP show_external_sync

show_internal_sync:	 ;  zobrazi cerne "I" vlevo nahore
	LDI data,0b01011101
	RCALL write_right
	LDI data,0b01000001
	RCALL write_right
	LDI data,0b01011101
	RCALL write_right
	RJMP show_X_sync_end

show_external_sync:
	LDI data,0b01000001
	RCALL write_right
	LDI data,0b01010101
	RCALL write_right
	LDI data,0b01011101
	RCALL write_right
	RJMP show_X_sync_end

show_no_sync:
	LDI data,0b01100011
	RCALL write_right
	LDI data,0b01011101
	RCALL write_right
	LDI data,0b01011101
	RCALL write_right
;	RJMP show_X_sync_end	; Zbytecne, PC si tam "dojde"
show_X_sync_end:
	LDI data,0b01111111
	RCALL write_right

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
show_coupling:
	LDI data,OSC_info_symbols_line
	RCALL select_line_right
	LDI data,53
	RCALL select_X_right
  ; Nyni se zapisi data na LCD. "A", nebo "D"
	LDS tmp,AC_DC_coupling_SRAM
	SBRC tmp,0	; Kontrola LSB - 0 -> AC, 1 -> DC

	RJMP show_coupling_DC

show_coupling_AC:
	LDI data,0b01000011
	RCALL write_right
	LDI data,0b01110101
	RCALL write_right
	LDI data,0b01000011
	RCALL write_right
	RJMP show_coupling_end

show_coupling_DC:
	LDI data,0b01000001
	RCALL write_right
	LDI data,0b01011101
	RCALL write_right
	LDI data,0b01100011
	RCALL write_right

show_coupling_end:
	LDI data,0b01111111
	RCALL write_right

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
show_trigger_single_mode:
	LDI data,OSC_info_symbols_line
	RCALL select_line_right
	LDI data,57
	RCALL select_X_right
  ; Nyni se zapisi data na LCD - "S"
	LDI data,0b01011011
	RCALL write_right
	LDI data,0b01010101
	RCALL write_right
	LDI data,0b01101101
	RCALL write_right
	LDI data,0b01111111
	RCALL write_right

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_time_base:
	LDS number,TimeBaseSRAM		; do "number" si ulozime informaci
  ; o zvolene casove zakladne

	LDI data,OSC_info_time_base_line
	RCALL select_line_right	; nastavime se na 2. radek (radek uplne
  ; "nahore" je cislovan 0 -> proto je vyse 1

	LDI data,101	; a dal nastavime parametr pro pismena. Ten rika, od
  ; jakeho bodu na Xove ose ma zacit vykreslovat. Zde se bere v uvahu displej
  ; jako celek (pro snazsi "psani" pismen na displej)
	CLT	; nastavime barvu pisma na cernou
; *-----------------------------------------*

  ; Nyni budeme postupne probirat vsechny moznosti


  ; Vzhledem k moznostem bufferu, je jeho max. vzorkovaci frekvence 20Mhz.
  ; Takze casove zakladny 207 a 208 je v podstate jen "zoom" casove zakladny
  ; 209 (0.5us/dilek - 50ns/pixel). To znamena, ze se bufferu odesle casova
  ; zakladna, prijmeme tato data, ale pri vykreslovani vykreslime jeden a ten
  ; samy box 2x, nebo 5x
num_207:
  ; Zoom - 5x
	CPI number,207	; kontrola, zda se nejedna o 207 (0.1us)
	BRNE num_208	; pokud ne, kontrola zda se nejedna o 208 atd...
  ; pokud se jedna o 207, pak se dostaneme sem

	LDI ZH,HIGH(2*TB_0p1)
	LDI ZL,LOW(2*TB_0p1)
	RCALL write_text_from_DB	; vypise na LCD "0.1"
	RJMP show_us_255_samples

  ; Zoom - 2x
num_208:	; 0.25us
	CPI number,208
	BRNE num_209

	LDI ZH,HIGH(2*TB_0p25)
	LDI ZL,LOW(2*TB_0p25)
	RCALL write_text_from_DB	; vypise na LCD "0.25"
	RJMP show_us_255_samples

  ; Uz periodicke vzorkovani
num_209:	; 0.5us
	CPI number,209
	BRNE num_210

	LDI ZH,HIGH(2*TB_0p5)
	LDI ZL,LOW(2*TB_0p5)
	RCALL write_text_from_DB
	RJMP show_us_255_samples

num_210:	; 1us
	CPI number,210
	BRNE num_211

	LDI ZH,HIGH(2*TB_1)
	LDI ZL,LOW(2*TB_1)
	RCALL write_text_from_DB
	RJMP show_us_255_samples

  ; Realtime vzorkovani
num_211:	; 2us
	CPI number,211
	BRNE num_212

  ; Tady je vyjimka. Resp. jako u vsech malych casovych zakladen, nastava
  ; problem s rychlosti ukladani vzorku do bufferu, takze jsou tady urcita
  ; omezeni. Proto se vola show_us_255_samples
	LDI ZH,HIGH(2*TB_2)
	LDI ZL,LOW(2*TB_2)
	RCALL write_text_from_DB
	RJMP show_us_255_samples

num_212:	; 5us
	CPI number,212
	BRNE num_213

	LDI ZH,HIGH(2*TB_5)
	LDI ZL,LOW(2*TB_5)
	RCALL write_text_from_DB
	RJMP show_us

num_213:	; 10us
	CPI number,213
	BRNE num_214

	LDI ZH,HIGH(2*TB_10)
	LDI ZL,LOW(2*TB_10)
	RCALL write_text_from_DB
	RJMP show_us

num_214:	; 20us
	CPI number,214
	BRNE num_215

	LDI ZH,HIGH(2*TB_20)
	LDI ZL,LOW(2*TB_20)
	RCALL write_text_from_DB
	RJMP show_us

num_215:	; 50us
	CPI number,215
	BRNE num_216

	LDI ZH,HIGH(2*TB_50)
	LDI ZL,LOW(2*TB_50)
	RCALL write_text_from_DB
	RJMP show_us

num_216:	; 0.1ms
	CPI number,216
	BRNE num_217

	LDI ZH,HIGH(2*TB_0p1)
	LDI ZL,LOW(2*TB_0p1)
	RCALL write_text_from_DB
	RJMP show_ms

num_217:	; 0.2ms
	CPI number,217
	BRNE num_218

	LDI ZH,HIGH(2*TB_0p2)
	LDI ZL,LOW(2*TB_0p2)
	RCALL write_text_from_DB
	RJMP show_ms

num_218:	; 0.5ms
	CPI number,218
	BRNE num_219

	LDI ZH,HIGH(2*TB_0p5)
	LDI ZL,LOW(2*TB_0p5)
	RCALL write_text_from_DB
	RJMP show_ms

num_219:	; 1ms
	CPI number,219
	BRNE num_220

	LDI ZH,HIGH(2*TB_1)
	LDI ZL,LOW(2*TB_1)
	RCALL write_text_from_DB
	RJMP show_ms

num_220:	; 2ms
	CPI number,220
	BRNE num_221

	LDI ZH,HIGH(2*TB_2)
	LDI ZL,LOW(2*TB_2)
	RCALL write_text_from_DB
	RJMP show_ms

num_221:	; 5ms
	CPI number,221
	BRNE num_222

	LDI ZH,HIGH(2*TB_5)
	LDI ZL,LOW(2*TB_5)
	RCALL write_text_from_DB
	RJMP show_ms

num_222:	; 10ms
	CPI number,222
	BRNE num_223

	LDI ZH,HIGH(2*TB_10)
	LDI ZL,LOW(2*TB_10)
	RCALL write_text_from_DB
	RJMP show_ms

num_223:	; 20ms
	CPI number,223
	BRNE num_224

	LDI ZH,HIGH(2*TB_20)
	LDI ZL,LOW(2*TB_20)
	RCALL write_text_from_DB
	RJMP show_ms

num_224:	; 50ms
	CPI number,224
	BRNE num_225

	LDI ZH,HIGH(2*TB_50)
	LDI ZL,LOW(2*TB_50)
	RCALL write_text_from_DB
	RJMP show_ms

num_225:	; 0.1s
	CPI number,225
	BRNE num_226

	LDI ZH,HIGH(2*TB_0p1)
	LDI ZL,LOW(2*TB_0p1)
	RCALL write_text_from_DB
	RJMP show_s

num_226:	; 0.2s
	CPI number,226
	BRNE num_227

	LDI ZH,HIGH(2*TB_0p2)
	LDI ZL,LOW(2*TB_0p2)
	RCALL write_text_from_DB
	RJMP show_s

num_227:	; 0.5s
	CPI number,227
	BRNE num_228

	LDI ZH,HIGH(2*TB_0p5)
	LDI ZL,LOW(2*TB_0p5)
	RCALL write_text_from_DB
	RJMP show_s

num_228:	; 1s
	CPI number,228
	BRNE num_229

	LDI ZH,HIGH(2*TB_1)
	LDI ZL,LOW(2*TB_1)
	RCALL write_text_from_DB
	RJMP show_s

num_229:	; 2s
	CPI number,229
	BRNE num_230

	LDI ZH,HIGH(2*TB_2)
	LDI ZL,LOW(2*TB_2)
	RCALL write_text_from_DB
	RJMP show_s

num_230:	; 5s
	CPI number,230
	BRNE num_231

	LDI ZH,HIGH(2*TB_5)
	LDI ZL,LOW(2*TB_5)
	RCALL write_text_from_DB
	RJMP show_s

; *-----------------------------------------*
  ; Pokud se dostaneme az sem, zvolena casova zakladna neexistuje
  ; (resp. obvod na ni neni pripraven) -> nastavi posledni zvolenou casovku

num_231:
	CPI number,216	; udelame porovnani,jestli je vetsi nebo mensi nez 216
	BRLO smallest_time_base	; pokud bude mensi jak 216, pak se zvoli
  ; nejmensi casova zakladna
	LDI number,230	; v opacnem pripade se zvoli nejvetsi casova zakladna
	STS TimeBaseSRAM,number	; informace se samozrejme ulozi do SRAM

	RJMP num_230

smallest_time_base:
	LDI number,207
	STS TimeBaseSRAM,number

	RJMP num_207
; *-----------------------------------------*
show_us_255_samples:
	LDI ZH,HIGH(2*TB_us)
	LDI ZL,LOW(2*TB_us)
	RCALL write_text_from_DB

	CPI number,211	; kontrola, zda se uz nejedna o periodicke vzorkovani
	BRSH show_us_255_samples_no_peiodic	; pokud je casova zakladna
  ; (byla predtim stazena do number) vetsi nebo rovna 211, pak se jeste
  ; nejedna o periodicke vzorkovani
	RCALL show_periodic_sampling

show_us_255_samples_no_peiodic:
	LDS tmp,number_of_samples_SRAM
	CPI tmp,255	; kontrola, zda je nastaveno 255 vzorku
	BREQ show_us_ms_s_end	; pokud ano, skok na show_us_ms_s_end

  ; Pokud ne, zmeni se pocet vzorku
	LDI tmp,255
	STS number_of_samples_SRAM,tmp
	CALL Calculate_samples_offset

  ; A provede se i reset bufferu, aby mel aktualni pocet vzorku
	CALL reset_buffer_and_send_cfg

	RET

show_us:
  ; zobrazi na konci us
	LDI ZH,HIGH(2*TB_us)
	LDI ZL,LOW(2*TB_us)
	RCALL write_text_from_DB
  ; A nastavime primereny pocet vzorku, pokud bude nastaven mod na "Auto"
	LDS tmp,number_of_samples_mode_SRAM
	CPI tmp,0	; kontrola, zda neni nastaven na 0 - mod Auto
	BREQ show_us_Auto	; pokud ano, pak se nastavi casovka
	RET	; pokud ne, nic se nenastavuje a pokracuje se dal

show_us_Auto:
  ; Nyni musime zjistit, zda nahadou neodpovida pocet vzorku ulozenych v SRAM
  ; s hodnotou 255 vzorku (v tomto pripade)
	LDS tmp,number_of_samples_SRAM
	CPI tmp,255
	BREQ show_us_ms_s_end	; pokud si budou rovny, neni potreba tuto
  ; hodnotu menit a znovu vypocitavat offset pro vzorky. Navic pri vypoctu
  ; offsetu se prepise i uzivatelem nastaveny posuv (offset, takze by
  ; posouvani de-facto nefungovalo)
	LDI tmp,255
	STS number_of_samples_SRAM,tmp
	CALL Calculate_samples_offset

  ; A provede se i reset bufferu, aby mel aktualni pocet vzorku
	CALL reset_buffer_and_send_cfg

	RET
show_ms:
  ; zobrazi na konci ms
	LDI ZH,HIGH(2*TB_ms)
	LDI ZL,LOW(2*TB_ms)
	RCALL write_text_from_DB

	LDS tmp,number_of_samples_mode_SRAM
	CPI tmp,0	; kontrola, zda neni nastaven na 0 - mod Auto
	BREQ show_ms_Auto	; pokud ano, pak se nastavi casovka
	RET	; pokud ne, nic se nenastavuje a pokracuje se dal

show_ms_Auto:
	LDS tmp,number_of_samples_SRAM
	CPI tmp,150
	BREQ show_us_ms_s_end
	LDI tmp,150
	STS number_of_samples_SRAM,tmp
	CALL Calculate_samples_offset
  ; A provede se i reset bufferu, aby mel aktualni pocet vzorku
	CALL reset_buffer_and_send_cfg

show_us_ms_s_end:	; Je to tady, kvuli tomu, ze BR** dokaze "skakat"
  ; jen o 64
	RET
show_s:
  ; zobrazi na konci s
	LDI ZH,HIGH(2*TB_s)
	LDI ZL,LOW(2*TB_s)
	RCALL write_text_from_DB
	LDS tmp,number_of_samples_mode_SRAM
	CPI tmp,0	; kontrola, zda neni nastaven na 0 - mod Auto
	BREQ show_s_Auto	; pokud ano, pak se nastavi casovka
	RET	; pokud ne, nic se nenastavuje a pokracuje se dal

show_s_Auto:
	LDS tmp,number_of_samples_SRAM
	CPI tmp,100
	BREQ show_us_ms_s_end
	LDI tmp,100
	STS number_of_samples_SRAM,tmp
	CALL Calculate_samples_offset

  ; A provede se i reset bufferu, aby mel aktualni pocet vzorku
	CALL reset_buffer_and_send_cfg

	RET

; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*

Show_voltage_range:
	LDS number,range_SRAM	; do number si ulozime informaci o rozsahu

	LDI data,OSC_info_voltage_range_line
	RCALL select_line_right	; nastavime se na 3. radek (radek uplne
  ; "nahore" je cislovan 0 -> proto je vyse 2

	LDI data,101	; a dal nastavime parametr pro pismena. Ten rika, od
  ; jakeho bodu na Xove ose ma zacit vykreslovat. Zde se bere v uvahu displej
  ; jako celek (pro snazsi "psani" pismen na displej)
	CLT	; nastavime barvu pisma na cernou

; *-----------------------------------------*
range_01Vdiv:
	CPI number,1
	BRNE range_02Vdiv

	LDI ZH,HIGH(2*Ran_0p1V)
	LDI ZL,LOW(2*Ran_0p1V)
	RCALL write_text_from_DB	; 0.1V
	RET

range_02Vdiv:
	CPI number,2
	BRNE range_05Vdiv

	LDI ZH,HIGH(2*Ran_0p2V)
	LDI ZL,LOW(2*Ran_0p2V)
	RCALL write_text_from_DB	; 0.2V
	RET

range_05Vdiv:
	CPI number,3
	BRNE range_1Vdiv

	LDI ZH,HIGH(2*Ran_0p5V)
	LDI ZL,LOW(2*Ran_0p5V)
	RCALL write_text_from_DB	; 0.5V
	RET

range_1Vdiv:
	CPI number,4
	BRNE range_2Vdiv

	LDI ZH,HIGH(2*Ran_1V)
	LDI ZL,LOW(2*Ran_1V)
	RCALL write_text_from_DB	; 1V
	RET

range_2Vdiv:
	CPI number,5
	BRNE range_5Vdiv

	LDI ZH,HIGH(2*Ran_2V)
	LDI ZL,LOW(2*Ran_2V)
	RCALL write_text_from_DB	; 2V
	RET

range_5Vdiv:
	CPI number,6
	BRNE range_unknownVdiv

	LDI ZH,HIGH(2*Ran_5V)
	LDI ZL,LOW(2*Ran_5V)
	RCALL write_text_from_DB	; 5V
	RET

range_unknownVdiv:
	LDI ZH,HIGH(2*Symbol_quest)
	LDI ZL,LOW(2*Symbol_quest)
	RCALL write_text_from_DB	; ?

	RET

; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_samples_results:


	RCALL Show_Vpp
	RCALL Show_Vmax

  ; Ted se zjisti, jestli nebyl vstupni signal detekovany jako sum
	LDS tmp,Samples_PERIOD_position_SRAM
	CPI tmp,$FF	; Porovnani s referencni hodnotou (nastavuje se na $FF
  ; pokud byl signal prilis maly)
	BRNE S_s_r_Show_results	; Pokud zde nebyla tato hodnota, pak signal
  ; nebyl vyhodnocen jako sum

  ; V opacnem pripade byl signal vyhodnocen jako sum -> dame o tom uzivateli
  ; vedet
S_s_r_noise:	; SUM
  ; Nastaveni radku na LCD
	LDI data,5
	RCALL select_line_right
  ; Nastaveni Xove souradnice
	LDI data,100

  ; Nastaveni slova 1 (Low)
	LDI ZH,HIGH(2*OI_Low)
	LDI ZL,LOW(2*OI_Low)

	RCALL write_text_from_DB

  ; Nastaveni radku na LCD
	LDI data,6
	RCALL select_line_right
  ; Nastaveni Xove souradnice
	LDI data,102

  ; Nastaveni slova 1 (signal)
	LDI ZH,HIGH(2*OI_signal)
	LDI ZL,LOW(2*OI_signal)

	RCALL write_text_from_DB
	RET


S_s_r_Show_results:	; KONTROLA, ZDA BYLA NALEZENA PERIODA
  ; Jeste je zde moznost, ze signal byl sice dostatecne veliky, ale nebyla
  ; nalezena perioda -> vypiseme "f not found"
	LDS tmp,Samples_PERIOD_value_SRAM
	CPI tmp,0
	BRNE S_s_r_Show_calc_results	; Pokud neni perioda 0, pak se vypisi
  ; namerene hodnoty

  ; V opacnem pripade vypiseme "f not found"

  ; Nastaveni radku na LCD
	LDI data,OSC_info_freq_not_found_line
	RCALL select_line_right
  ; Nastaveni Xove souradnice
	LDI data,100

  ; Nastaveni slova 1 (f not)
	LDI ZH,HIGH(2*OI_f_not)
	LDI ZL,LOW(2*OI_f_not)

	RCALL write_text_from_DB

  ; Nastaveni radku na LCD
	LDI data,OSC_info_freq_not_found_line+1
	RCALL select_line_right
  ; Nastaveni Xove souradnice
	LDI data,102

  ; Nastaveni slova 1 (found)
	LDI ZH,HIGH(2*OI_found)
	LDI ZL,LOW(2*OI_found)

	RCALL write_text_from_DB

	RET


S_s_r_Show_calc_results:	; VYSLEDKY
;	RCALL Show_T
	RCALL Show_f
	RCALL Show_VRMS
	RCALL Show_VAVG

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_Vpp:	; Zobrazi napeti peak-to-peak
  ; Stahne si vypoctenou hodnotu z pointeru X do A
	LDI XH,HIGH(Samples_PEAK_value_float_SRAM)
	LDI XL,LOW(Samples_PEAK_value_float_SRAM)
	CALL Save_X_to_A

  ; Nastaveni LCD
	LDI data,OSC_info_Vpp_line
	RCALL select_line_right	; Nastavime se na  3. radek
	LDI data,100	; Xova souradnice

	LDI tmp,1
	STS Font_micro_SRAM,tmp	; Nastaveni maleho pisma
	CALL Show_float_numkMG_20	; A vysledek se zobrazi na LCD

	LDI ZH,HIGH(2*Big_uV)
	LDI ZL,LOW(2*Big_uV)
	CALL write_char_from_flash	; A vykresli se jeste znak "V"

	LDI tmp,0
	STS Font_micro_SRAM,tmp	; nastaveni normalni velikosti pisma

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_Vmax:
  ; Stahne si vypoctenou hodnotu z pointeru X do A
	LDI XH,HIGH(Samples_VMAX_value_float_SRAM)
	LDI XL,LOW(Samples_VMAX_value_float_SRAM)
	CALL Save_X_to_A

  ; Nastaveni LCD
	LDI data,OSC_info_Vmax_line
	RCALL select_line_right	; Nastavime radek
  ; tady je jeste takovy mini ficura. Pokud cislo nebude zaprne, pak bude jeho
  ; souradnice 100, pokud zde bude znamenko minus, pak se posune na souradnici
  ; 97
	LDI XH,HIGH(Samples_VMAX_value_float_SRAM)
	LDI XL,LOW(Samples_VMAX_value_float_SRAM)
	LD tmp,X	; Stahneme si do "tmp" znamenko s exponentem

	LDI data,100	; Default je tedy 100
	SBRC tmp,7	; Pokud bude bez znamenka (kladne), pak se nasledujici
  ; instrukce preskoci a tim zustane xova souradnice 100. V opacnem pripade se
  ; souradnice prenastavi na 97
	LDI data,97	; Xova souradnice

	LDI tmp,1
	STS Font_micro_SRAM,tmp	; Nastaveni maleho pisma
	CALL Show_float_numkMG_20	; A vysledek se zobrazi na LCD

	LDI ZH,HIGH(2*Big_uV)
	LDI ZL,LOW(2*Big_uV)
	CALL write_char_from_flash	; A vykresli se jeste znak "V"

	LDI tmp,0
	STS Font_micro_SRAM,tmp	; nastaveni normalni velikosti pisma

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_T:	; Zobrazi periodu
	LDI XH,HIGH(Samples_PERIOD_value_float_SRAM)
	LDI XL,LOW(Samples_PERIOD_value_float_SRAM)
	CALL Save_X_to_A	;  A do "A" se ulozi vypocteny vysledek


  ; Nastaveni LCD
	LDI data,OSC_info_period_line
	RCALL select_line_right	; cislo radku
	LDI data,100		; xova souradnice

	LDI tmp,1
	STS Font_micro_SRAM,tmp	; male pismo
	CALL Show_float_numkMG_20	; Zobraz hodnotu

	LDI ZH,HIGH(2*Small_us)
	LDI ZL,LOW(2*Small_us)
	CALL write_char_from_flash	; zobraz koncovku "s"

	LDI tmp,0
	STS Font_micro_SRAM,tmp	; obnovit puvodni pismo (normalni)


	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_f:	; Zobrazi frekvenci
  ; nastavi se X pointer
	LDI XH,HIGH(Samples_FREQUENCY_value_float_SRAM)
	LDI XL,LOW(Samples_FREQUENCY_value_float_SRAM)
	CALL Save_X_to_A	; A do "A" se ulozi vypocteny vysledek

  ; Nastaveni LCD
	LDI data,OSC_info_freq_line
	RCALL select_line_right	; cislo radku
	LDI data,99		; xova souradnice

	LDI tmp,1
	STS Font_micro_SRAM,tmp	; male pismo
	CALL Show_float_numkMG_20	; Zobraz hodnotu

	LDI ZH,HIGH(2*Big_uh)
	LDI ZL,LOW(2*Big_uh)
	CALL write_char_from_flash	; zobraz koncovku "s"

	LDI ZH,HIGH(2*Small_uz)
	LDI ZL,LOW(2*Small_uz)
	CALL write_char_from_flash	; zobraz koncovku "s"


	LDI tmp,0
	STS Font_micro_SRAM,tmp	; obnovit puvodni pismo (normalni)


	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_VRMS:	; Zobrazi RMS napeti
	LDI XH,HIGH(Samples_VRMS_value_float_SRAM)
	LDI XL,LOW(Samples_VRMS_value_float_SRAM)
	CALL Save_X_to_A

  ; Nastaveni LCD
	LDI data,OSC_info_VRMS_line
	RCALL select_line_right	; Nastavime se na  3. radek
	LDI data,100	; Xova souradnice

	LDI tmp,1
	STS Font_micro_SRAM,tmp	; Nastaveni maleho pisma
	CALL Show_float_numkMG_20	; A vysledek se zobrazi na LCD

	LDI ZH,HIGH(2*Big_uV)
	LDI ZL,LOW(2*Big_uV)
	CALL write_char_from_flash	; A vykresli se jeste znak "V"

	LDI tmp,0
	STS Font_micro_SRAM,tmp	; nastaveni normalni velikosti pisma

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Show_VAVG:	; Zobrazi AVG napeti
	LDI XH,HIGH(Samples_VAVG_value_float_SRAM)
	LDI XL,LOW(Samples_VAVG_value_float_SRAM)
	CALL Save_X_to_A

  ; Nastaveni LCD
	LDI data,OSC_info_VAVG_line
	RCALL select_line_right	; Nastavime se na radek
  ; tady je jeste takovy mini ficura. Pokud cislo nebude zaprne, pak bude jeho
  ; souradnice 100, pokud zde bude znamenko minus, pak se posune na souradnici
  ; 97
	LDI XH,HIGH(Samples_VAVG_value_float_SRAM)
	LDI XL,LOW(Samples_VAVG_value_float_SRAM)
	LD tmp,X	; Stahneme si do "tmp" znamenko s exponentem

	LDI data,100	; Default je tedy 100
	SBRC tmp,7	; Pokud bude bez znamenka (kladne), pak se nasledujici
  ; instrukce preskoci a tim zustane xova souradnice 100. V opacnem pripade se
  ; souradnice prenastavi na 97
	LDI data,97	; Xova souradnice

	LDI tmp,1
	STS Font_micro_SRAM,tmp	; Nastaveni maleho pisma
	CALL Show_float_numkMG_20	; A vysledek se zobrazi na LCD

	LDI ZH,HIGH(2*Big_uV)
	LDI ZL,LOW(2*Big_uV)
	CALL write_char_from_flash	; A vykresli se jeste znak "V"

	LDI tmp,0
	STS Font_micro_SRAM,tmp	; nastaveni normalni velikosti pisma

	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Load_range_LSB_to_Z:	; Do ukazatele Z ulozi hodnotu LSB bitu. Od teto
  ; reference se vypocitava zmerene napeti
	LDS tmp,range_SRAM

L_r_L2Z_1:	; 0.1V
	CPI tmp,1
	BRNE L_r_L2Z_2
	LDI ZH,HIGH(2*Voltage_rng_01V)
	LDI ZL,LOW(2*Voltage_rng_01V)
	RET
L_r_L2Z_2:	; 0.2V
	CPI tmp,2
	BRNE L_r_L2Z_3
	LDI ZH,HIGH(2*Voltage_rng_02V)
	LDI ZL,LOW(2*Voltage_rng_02V)
	RET
L_r_L2Z_3:
	CPI tmp,3	; 0.5V
	BRNE L_r_L2Z_4
	LDI ZH,HIGH(2*Voltage_rng_05V)
	LDI ZL,LOW(2*Voltage_rng_05V)
	RET
L_r_L2Z_4:
	CPI tmp,4	; 1V
	BRNE L_r_L2Z_5
	LDI ZH,HIGH(2*Voltage_rng_1V)
	LDI ZL,LOW(2*Voltage_rng_1V)
	RET
L_r_L2Z_5:
	CPI tmp,5	; 2V
	BRNE L_r_L2Z_6
	LDI ZH,HIGH(2*Voltage_rng_2V)
	LDI ZL,LOW(2*Voltage_rng_2V)
	RET
L_r_L2Z_6:
	CPI tmp,6	; 5V
	BRNE L_r_L2Z_error
	LDI ZH,HIGH(2*Voltage_rng_5V)
	LDI ZL,LOW(2*Voltage_rng_5V)
	RET
L_r_L2Z_error:
	LDI ZH,HIGH(2*NULL)
	LDI ZL,LOW(2*NULL)
	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Load_10bit_range_LSB_to_Z:	; Do ukazatele Z ulozi hodnotu LSB bitu. Od teto
  ; reference se vypocitava zmerene napeti
	LDS tmp,range_SRAM

L_10b_r_L2Z_1:	; 0.1V
	CPI tmp,1
	BRNE L_10b_r_L2Z_2
	LDI ZH,HIGH(2*Voltage_rng_10b_01V)
	LDI ZL,LOW(2*Voltage_rng_10b_01V)
	RET
L_10b_r_L2Z_2:	; 0.2V
	CPI tmp,2
	BRNE L_10b_r_L2Z_3
	LDI ZH,HIGH(2*Voltage_rng_10b_02V)
	LDI ZL,LOW(2*Voltage_rng_10b_02V)
	RET
L_10b_r_L2Z_3:
	CPI tmp,3	; 0.5V
	BRNE L_10b_r_L2Z_4
	LDI ZH,HIGH(2*Voltage_rng_10b_05V)
	LDI ZL,LOW(2*Voltage_rng_10b_05V)
	RET
L_10b_r_L2Z_4:
	CPI tmp,4	; 1V
	BRNE L_10b_r_L2Z_5
	LDI ZH,HIGH(2*Voltage_rng_10b_1V)
	LDI ZL,LOW(2*Voltage_rng_10b_1V)
	RET
L_10b_r_L2Z_5:
	CPI tmp,5	; 2V
	BRNE L_10b_r_L2Z_6
	LDI ZH,HIGH(2*Voltage_rng_10b_2V)
	LDI ZL,LOW(2*Voltage_rng_10b_2V)
	RET
L_10b_r_L2Z_6:
	CPI tmp,6	; 5V
	BRNE L_10b_r_L2Z_error
	LDI ZH,HIGH(2*Voltage_rng_10b_5V)
	LDI ZL,LOW(2*Voltage_rng_10b_5V)
	RET
L_10b_r_L2Z_error:
	LDI ZH,HIGH(2*NULL)
	LDI ZL,LOW(2*NULL)
	RET
; *-----------------------------------------*
; |                                         |
; *-----------------------------------------*
Load_time_base_LSB_to_Z:	; Do ukazatele Z ulozi hodnotu jednoho bitu
  ; v case (casova jednotka pro jeden px)

	LDS tmp,TimeBaseSRAM
L_t_b_L2Z_207:
	CPI tmp,207
	BRNE L_t_b_L2Z_208

	LDI ZH,HIGH(2*Time_base_01us)
	LDI ZL,LOW(2*Time_base_01us)
	RET
L_t_b_L2Z_208:
	CPI tmp,208
	BRNE L_t_b_L2Z_209

	LDI ZH,HIGH(2*Time_base_025us)
	LDI ZL,LOW(2*Time_base_025us)
	RET
L_t_b_L2Z_209:
	CPI tmp,209
	BRNE L_t_b_L2Z_210

	LDI ZH,HIGH(2*Time_base_05us)
	LDI ZL,LOW(2*Time_base_05us)
	RET
L_t_b_L2Z_210:
	CPI tmp,210
	BRNE L_t_b_L2Z_211

	LDI ZH,HIGH(2*Time_base_1us)
	LDI ZL,LOW(2*Time_base_1us)
	RET
L_t_b_L2Z_211:
	CPI tmp,211
	BRNE L_t_b_L2Z_212

	LDI ZH,HIGH(2*Time_base_2us)
	LDI ZL,LOW(2*Time_base_2us)
	RET
L_t_b_L2Z_212:
	CPI tmp,212
	BRNE L_t_b_L2Z_213

	LDI ZH,HIGH(2*Time_base_5us)
	LDI ZL,LOW(2*Time_base_5us)
	RET
L_t_b_L2Z_213:
	CPI tmp,213
	BRNE L_t_b_L2Z_214

	LDI ZH,HIGH(2*Time_base_10us)
	LDI ZL,LOW(2*Time_base_10us)
	RET
L_t_b_L2Z_214:
	CPI tmp,214
	BRNE L_t_b_L2Z_215

	LDI ZH,HIGH(2*Time_base_20us)
	LDI ZL,LOW(2*Time_base_20us)
	RET
L_t_b_L2Z_215:
	CPI tmp,215
	BRNE L_t_b_L2Z_216

	LDI ZH,HIGH(2*Time_base_50us)
	LDI ZL,LOW(2*Time_base_50us)
	RET
L_t_b_L2Z_216:
	CPI tmp,216
	BRNE L_t_b_L2Z_217

	LDI ZH,HIGH(2*Time_base_01ms)
	LDI ZL,LOW(2*Time_base_01ms)
	RET
L_t_b_L2Z_217:
	CPI tmp,217
	BRNE L_t_b_L2Z_218

	LDI ZH,HIGH(2*Time_base_02ms)
	LDI ZL,LOW(2*Time_base_02ms)
	RET
L_t_b_L2Z_218:
	CPI tmp,218
	BRNE L_t_b_L2Z_219

	LDI ZH,HIGH(2*Time_base_05ms)
	LDI ZL,LOW(2*Time_base_05ms)
	RET
L_t_b_L2Z_219:
	CPI tmp,219
	BRNE L_t_b_L2Z_220

	LDI ZH,HIGH(2*Time_base_1ms)
	LDI ZL,LOW(2*Time_base_1ms)
	RET
L_t_b_L2Z_220:
	CPI tmp,220
	BRNE L_t_b_L2Z_221

	LDI ZH,HIGH(2*Time_base_2ms)
	LDI ZL,LOW(2*Time_base_2ms)
	RET
L_t_b_L2Z_221:
	CPI tmp,221
	BRNE L_t_b_L2Z_222

	LDI ZH,HIGH(2*Time_base_5ms)
	LDI ZL,LOW(2*Time_base_5ms)
	RET
L_t_b_L2Z_222:
	CPI tmp,222
	BRNE L_t_b_L2Z_223

	LDI ZH,HIGH(2*Time_base_10ms)
	LDI ZL,LOW(2*Time_base_10ms)
	RET
L_t_b_L2Z_223:
	CPI tmp,223
	BRNE L_t_b_L2Z_224

	LDI ZH,HIGH(2*Time_base_20ms)
	LDI ZL,LOW(2*Time_base_20ms)
	RET
L_t_b_L2Z_224:
	CPI tmp,224
	BRNE L_t_b_L2Z_225

	LDI ZH,HIGH(2*Time_base_50ms)
	LDI ZL,LOW(2*Time_base_50ms)
	RET
L_t_b_L2Z_225:
	CPI tmp,225
	BRNE L_t_b_L2Z_226

	LDI ZH,HIGH(2*Time_base_01s)
	LDI ZL,LOW(2*Time_base_01s)
	RET
L_t_b_L2Z_226:
	CPI tmp,226
	BRNE L_t_b_L2Z_227

	LDI ZH,HIGH(2*Time_base_02s)
	LDI ZL,LOW(2*Time_base_02s)
	RET
L_t_b_L2Z_227:
	CPI tmp,227
	BRNE L_t_b_L2Z_228

	LDI ZH,HIGH(2*Time_base_05s)
	LDI ZL,LOW(2*Time_base_05s)
	RET
L_t_b_L2Z_228:
	CPI tmp,228
	BRNE L_t_b_L2Z_229

	LDI ZH,HIGH(2*Time_base_1s)
	LDI ZL,LOW(2*Time_base_1s)
	RET
L_t_b_L2Z_229:
	CPI tmp,229
	BRNE L_t_b_L2Z_230

	LDI ZH,HIGH(2*Time_base_2s)
	LDI ZL,LOW(2*Time_base_2s)
	RET
L_t_b_L2Z_230:
	CPI tmp,230
	BRNE L_t_b_L2Z_error

	LDI ZH,HIGH(2*Time_base_5s)
	LDI ZL,LOW(2*Time_base_5s)
	RET
L_t_b_L2Z_error:	; Tato situace by nemela nikdy nastat
	LDI ZH,HIGH(2*NULL)
	LDI ZL,LOW(2*NULL)
	RET

