This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DisplayList.h
1874 lines (1705 loc) · 57.4 KB
/
DisplayList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
*/
#ifndef RF_DISPLAY
#define RF_DISPLAY
#if FEATURE_CONTROLLER == UICONFIG_CONTROLLER
#include "uiconfig.h"
#endif
// No controller at all
#if FEATURE_CONTROLLER == NO_CONTROLLER
#define UI_HAS_KEYS 0
#define UI_DISPLAY_TYPE NO_DISPLAY
#ifdef UI_MAIN
void uiInitKeys() {}
void uiCheckKeys(uint16_t &action) {}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif // UI_MAIN
#endif // NO_CONTROLLER
#if (FEATURE_CONTROLLER == CONTROLLER_SMARTRAMPS) || (FEATURE_CONTROLLER == CONTROLLER_GADGETS3D_SHIELD) || (FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD) || (FEATURE_CONTROLLER == CONTROLLER_BAM_DICE_DUE) || (FEATURE_CONTROLLER == CONTROLLER_REPRAPWORLD_GLCD)
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 0
#if FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD || (FEATURE_CONTROLLER == CONTROLLER_REPRAPWORLD_GLCD)
#define UI_DISPLAY_TYPE DISPLAY_U8G
#define U8GLIB_ST7920
#define UI_LCD_WIDTH 128
#define UI_LCD_HEIGHT 64
//select font size
#define UI_FONT_6X10 //default font
#ifdef UI_FONT_6X10
#define UI_FONT_WIDTH 6
#define UI_FONT_HEIGHT 10
#define UI_FONT_SMALL_HEIGHT 7
#define UI_FONT_DEFAULT repetier_6x10
#define UI_FONT_SMALL repetier_5x7
#define UI_FONT_SMALL_WIDTH 5 //smaller font for status display
#endif
//calculate rows and cols available with current font
#define UI_COLS (UI_LCD_WIDTH/UI_FONT_SMALL_WIDTH)
#define UI_ROWS (UI_LCD_HEIGHT/UI_FONT_HEIGHT)
#define UI_DISPLAY_CHARSET 3
#else // 40x4 char display
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 20
#define UI_ROWS 4
#endif
#define BEEPER_TYPE 1
#if FEATURE_CONTROLLER == CONTROLLER_GADGETS3D_SHIELD // Gadgets3d shield
#undef BEEPER_PIN
#define BEEPER_PIN 33
#define UI_DISPLAY_RS_PIN 16
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D0_PIN 23
#define UI_DISPLAY_D1_PIN 25
#define UI_DISPLAY_D2_PIN 27
#define UI_DISPLAY_D3_PIN 29
#define UI_DISPLAY_D4_PIN 23
#define UI_DISPLAY_D5_PIN 25
#define UI_DISPLAY_D6_PIN 27
#define UI_DISPLAY_D7_PIN 29
#define UI_ENCODER_A 35
#define UI_ENCODER_B 37
#define UI_ENCODER_CLICK 31
#define UI_RESET_PIN 41
#else // Smartcontroller
#if MOTHERBOARD == 701 // Megatronics v2.0
#define UI_DISPLAY_RS_PIN 14
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 15
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 30
#define UI_DISPLAY_D5_PIN 31
#define UI_DISPLAY_D6_PIN 32
#define UI_DISPLAY_D7_PIN 33
#define UI_ENCODER_A 61
#define UI_ENCODER_B 59
#define UI_ENCODER_CLICK 43
#define UI_RESET_PIN 66 // was 41 //AE3 was here and added this line 1/25/2014 (Note pin 41 is Y- endstop!)
#define UI_INVERT_MENU_DIRECTION 1
#elif MOTHERBOARD == 703 // Megatronics v3.0
#define UI_DISPLAY_RS_PIN 32
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 31
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 14
#define UI_DISPLAY_D5_PIN 30
#define UI_DISPLAY_D6_PIN 39
#define UI_DISPLAY_D7_PIN 15
#define UI_ENCODER_A 45
#define UI_ENCODER_B 44
#define UI_ENCODER_CLICK 33
#define UI_INVERT_MENU_DIRECTION 1
#define UI_RESET_PIN -1
#elif MOTHERBOARD == 80 // Rumba has different pins as RAMPS!
#undef BEEPER_PIN
#define BEEPER_PIN 44
#define UI_DISPLAY_RS_PIN 19
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 42
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 18
#define UI_DISPLAY_D5_PIN 38
#define UI_DISPLAY_D6_PIN 41
#define UI_DISPLAY_D7_PIN 40
#define UI_ENCODER_A 12
#define UI_ENCODER_B 11
#define UI_ENCODER_CLICK 43
#define UI_RESET_PIN 46
#elif MOTHERBOARD == 37 // UltiMaker 1.5.7
#undef BEEPER_PIN
#define BEEPER_PIN 18
#define UI_DISPLAY_RS_PIN 20
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 16
#define UI_DISPLAY_D5_PIN 21
#define UI_DISPLAY_D6_PIN 5
#define UI_DISPLAY_D7_PIN 6
#define UI_ENCODER_A 42
#define UI_ENCODER_B 40
#define UI_ENCODER_CLICK 19
#define UI_RESET_PIN -1
#elif MOTHERBOARD == 301 // Rambo has own pins layout
#undef BEEPER_PIN
#define BEEPER_PIN 79
#define UI_DISPLAY_RS_PIN 70
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 71
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 72
#define UI_DISPLAY_D5_PIN 73
#define UI_DISPLAY_D6_PIN 74
#define UI_DISPLAY_D7_PIN 75
#define UI_ENCODER_A 76
#define UI_ENCODER_B 77
#define UI_ENCODER_CLICK 78
#define UI_RESET_PIN 80
#undef SDCARDDETECT
#define SDCARDDETECT 81
#undef SDCARDDETECTINVERTED
#define SDCARDDETECTINVERTED 0
#undef SDSUPPORT
#define SDSUPPORT 1
#elif MOTHERBOARD == 501 // Alligator has own pins layout
#undef BEEPER_PIN
#define BEEPER_PIN 64
#define UI_DISPLAY_RS_PIN 18
#define UI_DISPLAY_ENABLE_PIN 15
#define UI_DISPLAY_D4_PIN 19
#define UI_ENCODER_A 14
#define UI_ENCODER_B 16
#define UI_ENCODER_CLICK 17
#define UI_RESET_PIN -1
#undef SDCARDDETECT
#define SDCARDDETECT 87
#undef SDCARDDETECTINVERTED
#define SDCARDDETECTINVERTED 0
#ifndef UI_VOLTAGE_LEVEL
#define UI_VOLTAGE_LEVEL 1 // Set 1=5 o 0=3.3 V
#endif
#elif ((MOTHERBOARD == 410) || (MOTHERBOARD == 411)) // DUE3DOM / DUE3DOM MINI has own pins layout
#undef BEEPER_PIN
#define BEEPER_PIN 41
#define UI_DISPLAY_RS_PIN 42
#define UI_DISPLAY_ENABLE_PIN 43
#define UI_DISPLAY_D4_PIN 44
#define UI_DISPLAY_D5_PIN 45
#define UI_DISPLAY_D6_PIN 46
#define UI_DISPLAY_D7_PIN 47
#define UI_ENCODER_A 52
#define UI_ENCODER_B 50
#define UI_ENCODER_CLICK 48
#define UI_RESET_PIN -1
#undef SDCARDDETECT
#define SDCARDDETECT 14
#undef SDCARDDETECTINVERTED
#define SDCARDDETECTINVERTED 0
#ifndef UI_VOLTAGE_LEVEL
#define UI_VOLTAGE_LEVEL 1 // Set 1=5 o 0=3.3 V
#endif
#elif MOTHERBOARD == 405 // Felix Pro 1
#undef BEEPER_PIN
#define BEEPER_PIN -1
#define UI_DISPLAY_RS_PIN 42
#define UI_DISPLAY_ENABLE_PIN 44
#define UI_DISPLAY_D4_PIN 43
#define UI_ENCODER_A 52
#define UI_ENCODER_B 50
#define UI_ENCODER_CLICK 48
#define UI_RESET_PIN -1
#elif MOTHERBOARD == 101 // Felix Pro 1
#undef BEEPER_PIN
#define BEEPER_PIN -1
#define UI_DISPLAY_RS_PIN 16
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D4_PIN 23
#define UI_ENCODER_A 35
#define UI_ENCODER_B 37
#define UI_ENCODER_CLICK 31
#define UI_RESET_PIN -1
#elif ( MOTHERBOARD == 183 ) || ( MOTHERBOARD == 184 ) // MJRice Pica
#undef BEEPER_PIN
#define BEEPER_PIN 19
#define UI_DISPLAY_RS_PIN 33
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 30
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 35
#define UI_DISPLAY_D5_PIN 32
#define UI_DISPLAY_D6_PIN 37
#define UI_DISPLAY_D7_PIN 36
#define UI_ENCODER_A 47
#define UI_ENCODER_B 48
#define UI_ENCODER_CLICK 31
#define UI_RESET_PIN -1
#define SDCARDDETECT 49
#elif ((MOTHERBOARD == 409)) // Ultratronics
#undef BEEPER_PIN
#define BEEPER_PIN 27
#define UI_DISPLAY_RS_PIN 62
#define UI_DISPLAY_ENABLE_PIN 75
#define UI_DISPLAY_D4_PIN 76
#define UI_DISPLAY_D5_PIN -1
#define UI_DISPLAY_D6_PIN -1
#define UI_DISPLAY_D7_PIN -1
#define UI_ENCODER_A 20
#define UI_ENCODER_B 21
#define UI_ENCODER_CLICK 64
#define UI_RESET_PIN -1
#undef SDCARDDETECT
#define SDCARDDETECT 60
#undef SDCARDDETECTINVERTED
#define SDCARDDETECTINVERTED 0
#elif MOTHERBOARD == 414 // RURAMPS4D
#undef BEEPER_PIN
#define BEEPER_PIN 62
#define UI_DISPLAY_RS_PIN 63
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 64
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 48
#define UI_DISPLAY_D5_PIN 50
#define UI_DISPLAY_D6_PIN 52
#define UI_DISPLAY_D7_PIN 53
#define UI_ENCODER_A 42
#define UI_ENCODER_B 44
#define UI_ENCODER_CLICK 40
#define UI_RESET_PIN -1
#define UI_INVERT_MENU_DIRECTION 1
#else // RAMPS
#undef BEEPER_PIN
#define BEEPER_PIN 37
#define UI_DISPLAY_RS_PIN 16
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D0_PIN 23
#define UI_DISPLAY_D1_PIN 25
#define UI_DISPLAY_D2_PIN 27
#define UI_DISPLAY_D3_PIN 29
#define UI_DISPLAY_D4_PIN 23
#define UI_DISPLAY_D5_PIN 25
#define UI_DISPLAY_D6_PIN 27
#define UI_DISPLAY_D7_PIN 29
#define UI_ENCODER_A 33
#define UI_ENCODER_B 31
#define UI_ENCODER_CLICK 35
#define UI_RESET_PIN 41
#endif
#endif // smartcontroller
#if (FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD) && (MOTHERBOARD == 63) //Melzi V2 + ReprapDiscount GLCD (such as Wanhao Duplicator i3)
#define BEEPER_PIN 27
#define UI_DISPLAY_RS_PIN 17
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 16
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 11
#define UI_DISPLAY_D5_PIN -1
#define UI_DISPLAY_D6_PIN -1
#define UI_DISPLAY_D7_PIN -1
#define UI_ENCODER_A 29
#define UI_ENCODER_B 30
#define UI_ENCODER_CLICK 28
#define UI_RESET_PIN 10
#define SDCARDDETECT -1
#endif
#define UI_DELAYPERCHAR 50
#if FEATURE_CONTROLLER == CONTROLLER_BAM_DICE_DUE
#define UI_ENCODER_SPEED 2
#endif
#ifndef UI_INVERT_MENU_DIRECTION
#define UI_INVERT_MENU_DIRECTION 0
#endif
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); // push button, connects gnd to pin
#if UI_RESET_PIN > -1
UI_KEYS_INIT_BUTTON_LOW(UI_RESET_PIN); // Kill pin
#endif
}
void uiCheckKeys(uint16_t &action) {
#if FEATURE_CONTROLLER == CONTROLLER_BAM_DICE_DUE
UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_B, UI_ENCODER_A); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
#else
UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A, UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
#endif
UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK, UI_ACTION_OK); // push button, connects gnd to pin
#if UI_RESET_PIN > -1
UI_KEYS_BUTTON_LOW(UI_RESET_PIN, UI_ACTION_RESET);
#endif
}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif
#endif // Controller 2 and 10
#if FEATURE_CONTROLLER == CONTROLLER_ADAFRUIT
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE DISPLAY_I2C
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 16
#define UI_ROWS 2
#define UI_DISPLAY_I2C_CHIPTYPE 1
#define UI_DISPLAY_I2C_ADDRESS 0x40
#define UI_DISPLAY_I2C_OUTPUT_PINS 65504
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 31
#define UI_I2C_CLOCKSPEED 400000L
#define UI_DISPLAY_RS_PIN _BV(15)
#define UI_DISPLAY_RW_PIN _BV(14)
#define UI_DISPLAY_ENABLE_PIN _BV(13)
#define UI_DISPLAY_D0_PIN _BV(12)
#define UI_DISPLAY_D1_PIN _BV(11)
#define UI_DISPLAY_D2_PIN _BV(10)
#define UI_DISPLAY_D3_PIN _BV(9)
#define UI_DISPLAY_D4_PIN _BV(12)
#define UI_DISPLAY_D5_PIN _BV(11)
#define UI_DISPLAY_D6_PIN _BV(10)
#define UI_DISPLAY_D7_PIN _BV(9)
#define UI_INVERT_MENU_DIRECTION 1
#define UI_HAS_I2C_KEYS
#define UI_HAS_I2C_ENCODER 0
#define UI_I2C_KEY_ADDRESS 0x40
#ifdef UI_MAIN
void uiInitKeys() {}
void uiCheckKeys(uint16_t &action) {}
inline void uiCheckSlowEncoder() {
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_WRITE);
HAL::i2cWrite(0x12); // GIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_READ);
uint16_t keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak() << 8);
HAL::i2cStop();
}
void uiCheckSlowKeys(uint16_t &action) {
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_WRITE);
HAL::i2cWrite(0x12); // GPIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_READ);
uint16_t keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak() << 8);
HAL::i2cStop();
UI_KEYS_I2C_BUTTON_LOW(4, UI_ACTION_PREVIOUS); // Up button
UI_KEYS_I2C_BUTTON_LOW(8, UI_ACTION_NEXT); // down button
UI_KEYS_I2C_BUTTON_LOW(16, UI_ACTION_BACK); // left button
UI_KEYS_I2C_BUTTON_LOW(2, UI_ACTION_OK); // right button
UI_KEYS_I2C_BUTTON_LOW(1, UI_ACTION_MENU_QUICKSETTINGS); //Select button
}
#endif
#endif // Controller 3
#if FEATURE_CONTROLLER == CONTROLLER_FOLTYN
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 2
#define UI_COLS 20
#define UI_ROWS 4
// PINK.1, 88, D_RS
#define UI_DISPLAY_RS_PIN 63
#define UI_DISPLAY_RW_PIN -1
// PINK.3, 86, D_E
#define UI_DISPLAY_ENABLE_PIN 65
// PINF.5, 92, D_D4
#define UI_DISPLAY_D0_PIN 59
// PINK.2, 87, D_D5
#define UI_DISPLAY_D1_PIN 64
// PINL.5, 40, D_D6
#define UI_DISPLAY_D2_PIN 44
// PINK.4, 85, D_D7
#define UI_DISPLAY_D3_PIN 66
// PINF.5, 92, D_D4
#define UI_DISPLAY_D4_PIN 59
// PINK.2, 87, D_D5
#define UI_DISPLAY_D5_PIN 64
// PINL.5, 40, D_D6
#define UI_DISPLAY_D6_PIN 44
// PINK.4, 85, D_D7
#define UI_DISPLAY_D7_PIN 66
#define UI_DELAYPERCHAR 50
#define UI_INVERT_MENU_DIRECTION 0
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_BUTTON_LOW(4); // push button, connects gnd to pin
UI_KEYS_INIT_BUTTON_LOW(5);
UI_KEYS_INIT_BUTTON_LOW(6);
UI_KEYS_INIT_BUTTON_LOW(11);
UI_KEYS_INIT_BUTTON_LOW(42);
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_BUTTON_LOW(4, UI_ACTION_OK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(5, UI_ACTION_NEXT); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(6, UI_ACTION_PREVIOUS); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(11, UI_ACTION_BACK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(42, UI_ACTION_SD_PRINT ); // push button, connects gnd to pin
}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif
#endif // Controller 4
#if FEATURE_CONTROLLER == CONTROLLER_VIKI // Viki Lcd
// You need to change these 3 button according to the positions
// where you put them into your board!
#define UI_ENCODER_A 7
#define UI_ENCODER_B 22
#define UI_RESET_PIN 32
// Set to -1 if you have not connected that pin
#define SDCARDDETECT 49
#define SDSS 53
#undef SDSUPPORT
#define SDSUPPORT 1
#define SDCARDDETECTINVERTED 0
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE DISPLAY_I2C
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 20
#define UI_ROWS 4
#define UI_DISPLAY_I2C_CHIPTYPE 1
#define UI_DISPLAY_I2C_ADDRESS 0x40
#define UI_DISPLAY_I2C_OUTPUT_PINS 0xFFE0
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0x01C0 // bits that are high always, for now the 3 viki leds
#define UI_DISPLAY_I2C_PULLUP 0x001F
#define UI_I2C_CLOCKSPEED 100000L // Note with very long cables make this much smaller, for 2ft cables I found 80000 worked ok
#define UI_DISPLAY_RS_PIN _BV(15)
#define UI_DISPLAY_RW_PIN _BV(14)
#define UI_DISPLAY_ENABLE_PIN _BV(13)
#define UI_DISPLAY_D0_PIN _BV(12)
#define UI_DISPLAY_D1_PIN _BV(11)
#define UI_DISPLAY_D2_PIN _BV(10)
#define UI_DISPLAY_D3_PIN _BV(9)
#define UI_DISPLAY_D4_PIN _BV(12)
#define UI_DISPLAY_D5_PIN _BV(11)
#define UI_DISPLAY_D6_PIN _BV(10)
#define UI_DISPLAY_D7_PIN _BV(9)
#undef BEEPER_PIN
#define BEEPER_PIN _BV(5)
#define BEEPER_TYPE 2
#define BEEPER_ADDRESS UI_DISPLAY_I2C_ADDRESS // I2C address of the chip with the beeper pin
#define UI_I2C_HEATBED_LED _BV(8)
#define UI_I2C_HOTEND_LED _BV(7)
#define UI_I2C_FAN_LED _BV(6)
#define UI_INVERT_MENU_DIRECTION 0
#define UI_HAS_I2C_KEYS
#define UI_HAS_I2C_ENCODER 0
#define UI_I2C_KEY_ADDRESS 0x40
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B); // click encoder on real pins. Phase is connected with gnd for signals.
UI_KEYS_INIT_BUTTON_LOW(UI_RESET_PIN); // Kill pin
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A, UI_ENCODER_B); // click encoder on real pins
UI_KEYS_BUTTON_LOW(UI_RESET_PIN, UI_ACTION_RESET);
}
inline void uiCheckSlowEncoder() { }// not used in Viki
void uiCheckSlowKeys(uint16_t &action) {
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_WRITE);
HAL::i2cWrite(0x12); // GPIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_READ);
unsigned int keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak() << 8);
HAL::i2cStop();
UI_KEYS_I2C_BUTTON_LOW(4, UI_ACTION_MENU_SDCARD); // Up button
UI_KEYS_I2C_BUTTON_LOW(8, UI_ACTION_MENU_QUICKSETTINGS); // down button
UI_KEYS_I2C_BUTTON_LOW(16, UI_ACTION_BACK); // left button
UI_KEYS_I2C_BUTTON_LOW(2, UI_ACTION_MENU_POSITIONS); // right button
UI_KEYS_I2C_BUTTON_LOW(1, UI_ACTION_OK); //Select button
}
#endif
#endif // Controller 5
#if FEATURE_CONTROLLER == CONTROLLER_MEGATRONIC
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 0
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 0
#define UI_COLS 20
#define UI_ROWS 2
#if MOTHERBOARD==701 // Megatronics v2.0
#define UI_DISPLAY_RS_PIN 14
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 15
#define UI_DISPLAY_D4_PIN 30
#define UI_DISPLAY_D5_PIN 31
#define UI_DISPLAY_D6_PIN 32
#define UI_DISPLAY_D7_PIN 33
#define UI_ENCODER_A 61
#define UI_ENCODER_B 59
#define UI_ENCODER_CLICK 43
#define UI_SHIFT_OUT 17
#define UI_SHIFT_LD 42
#define UI_SHIFT_CLK 63
#else // RAMPS 1.4
#define UI_DISPLAY_RS_PIN 16
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D4_PIN 23
#define UI_DISPLAY_D5_PIN 25
#define UI_DISPLAY_D6_PIN 27
#define UI_DISPLAY_D7_PIN 29
#define UI_ENCODER_A 64
#define UI_ENCODER_B 59
#define UI_ENCODER_CLICK 63
#define UI_SHIFT_OUT 40
#define UI_SHIFT_LD 42
#define UI_SHIFT_CLK 44
#endif
#define UI_DELAYPERCHAR 50
#define UI_INVERT_MENU_DIRECTION 1
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B);
UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK);
SET_OUTPUT(UI_SHIFT_CLK);
SET_OUTPUT(UI_SHIFT_LD);
SET_INPUT(UI_SHIFT_OUT);
WRITE(UI_SHIFT_OUT, HIGH);
WRITE(UI_SHIFT_LD, HIGH);
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A, UI_ENCODER_B);
UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK, UI_ACTION_OK);
}
inline void uiCheckSlowEncoder() {} // not used
void uiCheckSlowKeys(uint16_t &action) {
WRITE(UI_SHIFT_LD, LOW);
WRITE(UI_SHIFT_LD, HIGH);
for (int8_t i = 1; i <= 8; i++) {
if (!READ(UI_SHIFT_OUT)) { // pressed button = logical 0 (false)
switch (i) {
case 1: action = UI_ACTION_Z_DOWN; break; // F3
case 2: action = UI_ACTION_Z_UP; break; // F2
case 3: action = UI_ACTION_EMERGENCY_STOP; break; // F1
case 4: action = UI_ACTION_Y_UP; break; // UP
case 5: action = UI_ACTION_X_UP; break; // RIGHT
case 6: action = UI_ACTION_HOME_ALL; break; // MID
case 7: action = UI_ACTION_Y_DOWN; break; // DOWN
case 8: action = UI_ACTION_X_DOWN; break; // LEFT
}
i = 9; // if button detected, exit "for loop"
}
WRITE(UI_SHIFT_CLK, HIGH);
WRITE(UI_SHIFT_CLK, LOW);
}
}
#endif
#endif // Controller 6
#if FEATURE_CONTROLLER == CONTROLLER_RADDS
#undef SDSS
#define SDSS 10
#undef SPI_PIN
#define SPI_PIN 77
#undef SPI_CHAN
#define SPI_CHAN 0
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 1
#define BEEPER_TYPE 1
#define UI_COLS 20
#define UI_ROWS 4
#undef BEEPER_PIN
#define BEEPER_PIN 41
#define UI_DISPLAY_RS_PIN 42
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 43
#define UI_DISPLAY_D0_PIN 44
#define UI_DISPLAY_D1_PIN 45
#define UI_DISPLAY_D2_PIN 46
#define UI_DISPLAY_D3_PIN 47
#define UI_DISPLAY_D4_PIN 44
#define UI_DISPLAY_D5_PIN 45
#define UI_DISPLAY_D6_PIN 46
#define UI_DISPLAY_D7_PIN 47
#define UI_ENCODER_A 50
#define UI_ENCODER_B 52
#define UI_ENCODER_CLICK 48
#define UI_RESET_PIN -1
#define UI_DELAYPERCHAR 50
#define UI_INVERT_MENU_DIRECTION 0
#define UI_BUTTON_BACK 71
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); // push button, connects gnd to pin
UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_BACK);
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK, UI_ACTION_OK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(UI_BUTTON_BACK, UI_ACTION_BACK);
}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif
#endif // Controller 7
#if FEATURE_CONTROLLER == CONTROLLER_PIBOT20X4 || FEATURE_CONTROLLER == CONTROLLER_PIBOT16X2
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 1
#define UI_DELAYPERCHAR 50
#define UI_INVERT_MENU_DIRECTION 1
#define BEEPER_SHORT_SEQUENCE 6,2 // Needs longer beep sequence
#define BEEPER_LONG_SEQUENCE 24,8
#define BEEPER_TYPE 1
#define BEEPER_TYPE_INVERTING 0
#if FEATURE_CONTROLLER == CONTROLLER_PIBOT16X2
#define UI_COLS 16
#define UI_ROWS 2
#else ////20x04 Display
#define UI_COLS 20
#define UI_ROWS 4
#endif
#ifdef PiBot_V_1_4
#undef BEEPER_PIN
#define BEEPER_PIN 31
#define UI_DISPLAY_RS_PIN 45
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 44
#define UI_DISPLAY_D0_PIN 43
#define UI_DISPLAY_D1_PIN 42
#define UI_DISPLAY_D2_PIN 19
#define UI_DISPLAY_D3_PIN 18
#define UI_DISPLAY_D4_PIN 43
#define UI_DISPLAY_D5_PIN 42
#define UI_DISPLAY_D6_PIN 19
#define UI_DISPLAY_D7_PIN 18
#define UI_ENCODER_A 61
#define UI_ENCODER_B 62
#define UI_ENCODER_CLICK 63
#define UI_RESET_PIN 28
#define UI_DELAYPERCHAR 50
#define UI_BUTTON_OK 49
#define UI_BUTTON_NEXT 48
#define UI_BUTTON_PREVIOUS 47
#define UI_BUTTON_BACK 46
#define UI_BUTTON_SD_PRINT 29
#endif
#if PiBot_V_1_4==true || PiBot_V_1_6==true
#undef BEEPER_PIN
#define BEEPER_PIN 37
#define UI_DISPLAY_RS_PIN 16
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D0_PIN 23
#define UI_DISPLAY_D1_PIN 25
#define UI_DISPLAY_D2_PIN 27
#define UI_DISPLAY_D3_PIN 29
#define UI_DISPLAY_D4_PIN 23
#define UI_DISPLAY_D5_PIN 25
#define UI_DISPLAY_D6_PIN 27
#define UI_DISPLAY_D7_PIN 29
#define UI_ENCODER_A 33
#define UI_ENCODER_B 31
#define UI_ENCODER_CLICK 35
#define UI_RESET_PIN 41
#define UI_DELAYPERCHAR 50
#define UI_BUTTON_OK 4
#define UI_BUTTON_NEXT 6
#define UI_BUTTON_PREVIOUS 5
#define UI_BUTTON_BACK 11
#define UI_BUTTON_SD_PRINT 42
#endif
#if PiBot_V_2_0
#undef BEEPER_PIN
#define BEEPER_PIN 16
#define UI_DISPLAY_RS_PIN 43
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 42
#define UI_DISPLAY_D0_PIN 19
#define UI_DISPLAY_D1_PIN 18
#define UI_DISPLAY_D2_PIN 38
#define UI_DISPLAY_D3_PIN 41
#define UI_DISPLAY_D4_PIN 19
#define UI_DISPLAY_D5_PIN 18
#define UI_DISPLAY_D6_PIN 38
#define UI_DISPLAY_D7_PIN 41
#define UI_ENCODER_A 37
#define UI_ENCODER_B 36
// Vick BTN
#define UI_ENCODER_CLICK 69
// if you want, you can get the CNC Pin used 11
#define UI_RESET_PIN -1
#define UI_DELAYPERCHAR 320
#define UI_BUTTON_OK 47
#define UI_BUTTON_NEXT 46
#define UI_BUTTON_PREVIOUS 45
#define UI_BUTTON_BACK 44
// if you want, you can get the CNC Pin used 10
#define UI_BUTTON_SD_PRINT 70
#endif
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_OK); // push button, connects gnd to pin
UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_NEXT);
UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_PREVIOUS);
UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_BACK);
UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_SD_PRINT);
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_BUTTON_LOW(UI_BUTTON_OK, UI_ACTION_OK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(UI_BUTTON_NEXT, UI_ACTION_NEXT); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(UI_BUTTON_PREVIOUS, UI_ACTION_PREVIOUS); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(UI_BUTTON_BACK, UI_ACTION_BACK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(UI_BUTTON_SD_PRINT, UI_ACTION_SD_PRINT ); // push button, connects gnd to pin
}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif
#endif
#if FEATURE_CONTROLLER == CONTROLLER_FELIX
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 0
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 20
#define UI_ROWS 4
#define UI_ENCODER_SPEED 2
#undef BEEPER_TYPE
#define BEEPER_TYPE 0
#undef BEEPER_PIN
#define BEEPER_PIN -1
#define UI_DISPLAY_RS_PIN 16
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 17
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 23
#define UI_DISPLAY_D5_PIN 25
#define UI_DISPLAY_D6_PIN 27
#define UI_DISPLAY_D7_PIN 29
#define UI_ENCODER_A 35
#define UI_ENCODER_B 37
#define UI_ENCODER_CLICK 31
#define UI_DELAYPERCHAR 50
#define UI_INVERT_MENU_DIRECTION 0
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); // push button, connects gnd to pin
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A, UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK, UI_ACTION_OK); // push button, connects gnd to pin
}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif
#endif // Controller 12
#if FEATURE_CONTROLLER == CONTROLLER_RAMBO // SeeMeCNC LCD + Rambo
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 0
#define UI_DISPLAY_TYPE DISPLAY_4BIT
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 20
#define UI_ROWS 4
#define BEEPER_TYPE 1
#undef BEEPER_PIN
#define BEEPER_PIN 79
#define UI_DISPLAY_RS_PIN 70
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 71
#define UI_DISPLAY_D0_PIN -1
#define UI_DISPLAY_D1_PIN -1
#define UI_DISPLAY_D2_PIN -1
#define UI_DISPLAY_D3_PIN -1
#define UI_DISPLAY_D4_PIN 72
#define UI_DISPLAY_D5_PIN 73
#define UI_DISPLAY_D6_PIN 74
#define UI_DISPLAY_D7_PIN 75
#define UI_ENCODER_A 76
#define UI_ENCODER_B 77
#define UI_ENCODER_CLICK 78
#define UI_KILL_PIN 80
#define UI_DELAYPERCHAR 50
#define UI_INVERT_MENU_DIRECTION 0
#ifdef UI_MAIN
void uiInitKeys() {
UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A, UI_ENCODER_B);
UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK);
UI_KEYS_INIT_BUTTON_LOW(UI_KILL_PIN);
}
void uiCheckKeys(uint16_t &action) {
UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A, UI_ENCODER_B);
UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK, UI_ACTION_OK);
UI_KEYS_BUTTON_LOW(UI_KILL_PIN, UI_ACTION_KILL);
}
inline void uiCheckSlowEncoder() {}
void uiCheckSlowKeys(uint16_t &action) {}
#endif
#endif // Controller 13
#if FEATURE_CONTROLLER == CONTROLLER_OPENHARDWARE_LCD2004
#undef SDSUPPORT
#define SDSUPPORT 1
#define SDCARDDETECT -1
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE DISPLAY_I2C
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 20
#define UI_ROWS 4
#define UI_DISPLAY_I2C_CHIPTYPE 1
#define UI_DISPLAY_I2C_ADDRESS 0x40
#define UI_DISPLAY_I2C_OUTPUT_PINS 65504
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 31
#define UI_I2C_CLOCKSPEED 400000L
#define UI_DISPLAY_RS_PIN _BV(15)
#define UI_DISPLAY_RW_PIN _BV(14)
#define UI_DISPLAY_ENABLE_PIN _BV(13)
#define UI_DISPLAY_D0_PIN _BV(12)
#define UI_DISPLAY_D1_PIN _BV(11)
#define UI_DISPLAY_D2_PIN _BV(10)
#define UI_DISPLAY_D3_PIN _BV(9)
#define UI_DISPLAY_D4_PIN _BV(12)
#define UI_DISPLAY_D5_PIN _BV(11)
#define UI_DISPLAY_D6_PIN _BV(10)
#define UI_DISPLAY_D7_PIN _BV(9)
#define UI_INVERT_MENU_DIRECTION false
#define UI_HAS_I2C_KEYS
#define UI_HAS_I2C_ENCODER 0
#define UI_I2C_KEY_ADDRESS 0x40
#ifdef UI_MAIN
void uiInitKeys() {}
void uiCheckKeys(uint16_t &action) {}
inline void uiCheckSlowEncoder() {
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_WRITE);
HAL::i2cWrite(0x12); // GIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_READ);
uint16_t keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak() << 8);
HAL::i2cStop();
}
void uiCheckSlowKeys(uint16_t &action) {
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_WRITE);
HAL::i2cWrite(0x12); // GPIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS + I2C_READ);
uint16_t keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak() << 8);
HAL::i2cStop();
UI_KEYS_I2C_BUTTON_LOW(_BV(4), UI_ACTION_OK); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(1), UI_ACTION_BACK); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(0), UI_ACTION_SD_PRINT); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(3), UI_ACTION_PREVIOUS); // Up button
UI_KEYS_I2C_BUTTON_LOW(_BV(2), UI_ACTION_NEXT); // down button
}
#endif
#endif // Controller 14
/*
Sanguinololu + panelolu2
*/
#if FEATURE_CONTROLLER == CONTROLLER_SANGUINOLOLU_PANELOLU2
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 0
#define UI_DISPLAY_TYPE DISPLAY_I2C