refactoors
[mTask.git] / mTaskLCD.dcl
1 definition module mTaskLCD
2
3 import mTask
4
5 :: LCD =
6 { cursorRow :: Int
7 , cursorCol :: Int
8 , sizeH :: Int
9 , sizeW :: Int
10 , lcdtxt :: [String]
11 }
12
13 :: Button = RightButton | UpButton | DownButton | LeftButton | SelectButton | NoButton
14
15 class lcd v where
16 begin :: (v LCD Expr) (v Int p) (v Int q) -> v () Expr
17 print :: (v LCD Expr) (v t p) -> v Int Expr | stringQuotes t // returns bytes written
18 setCursor :: (v LCD Expr) (v Int p) (v Int q) -> v () Expr
19 liquidCrystal0 :: [DigitalPin] ((v LCD Expr)->Main (v b q)) -> Main (v b q)
20 LCD :: Int Int [DigitalPin] ((v LCD Expr)->Main (v b q)) -> Main (v b q)
21 scrollLeft :: (v LCD Expr) -> v () Expr
22 scrollRight :: (v LCD Expr) -> v () Expr
23 pressed :: (v Button Expr) -> v Bool Expr
24
25 instance lcd Code
26 instance lcd Eval
27
28 printAt :: (v LCD Expr) (v Int b) (v Int c) (v t e) -> v Int Stmt | lcd, seq v & stringQuotes t
29 keySwitch :: (a Int b) (a c d,a c e,a c f,a c g,a c h,a c a0) -> a c Stmt | arith, boolExpr, seq a & If a h a0 b0 & If a g b0 c0 & If a f c0 d0 & If a e d0 e0 & If a d e0 f0 & type c
30
31 derive toGenDynamic LCD
32 derive fromGenDynamic LCD
33
34 instance toCode Button
35
36 RightBound :== 50
37 UpBound :== 190
38 DownBound :== 380
39 LeftBound :== 555
40 SelectBound :== 790
41
42 rightButton :== lit RightButton
43 upButton :== lit UpButton
44 downButton :== lit DownButton
45 leftButton :== LeftButton
46 selectButton :== lit SelectButton
47 noButton :== lit NoButton