summaryrefslogtreecommitdiff
path: root/apps/plugins/periodic_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/periodic_table.c')
-rw-r--r--apps/plugins/periodic_table.c106
1 files changed, 20 insertions, 86 deletions
diff --git a/apps/plugins/periodic_table.c b/apps/plugins/periodic_table.c
index 876de66615..c4622e3934 100644
--- a/apps/plugins/periodic_table.c
+++ b/apps/plugins/periodic_table.c
@@ -71,8 +71,8 @@ static const struct periodic_element_t periodic_elements[] = {
71 { 18, 3, 18, "Ar", "Argon", "39.948", "1.7837", "-189.2", "-185.86", 'p', 9 , 9, 35}, 71 { 18, 3, 18, "Ar", "Argon", "39.948", "1.7837", "-189.2", "-185.86", 'p', 9 , 9, 35},
72 { 1, 4, 19, "K", "Potassium", "39.0983", "0.862", "63.65", "765", 's', 1 , 10, 36}, 72 { 1, 4, 19, "K", "Potassium", "39.0983", "0.862", "63.65", "765", 's', 1 , 10, 36},
73 { 2, 4, 20, "Ca", "Calcium", "40.078", "1.55", "842", "1503", 's', 2 , 11, 37}, 73 { 2, 4, 20, "Ca", "Calcium", "40.078", "1.55", "842", "1503", 's', 2 , 11, 37},
74 { 3, 4, 21, "Sc", "Scandium", "44.955912", "2.989", "1539", "2831", 'd', 3 , 38, 38}, 74 { 3, 4, 21, "Sc", "Scandium", "44.955912", "2.989", "1539", "2831", 'd', 3 , 102, 38},
75 { 4, 4, 22, "Ti", "Titanium", "47.867", "4.54", "1666", "3289", 'd', 3 , 103, 39}, 75 { 4, 4, 22, "Ti", "Titanium", "47.867", "4.54", "1666", "3289", 'd', 3 , 88, 39},
76 { 5, 4, 23, "V", "Vanadium", "50.9415", "6.11", "1917", "3420", 'd', 3 , 104, 40}, 76 { 5, 4, 23, "V", "Vanadium", "50.9415", "6.11", "1917", "3420", 'd', 3 , 104, 40},
77 { 6, 4, 24, "Cr", "Chromium", "51.9961", "7.20", "1857", "2682", 'd', 3 , 105, 41}, 77 { 6, 4, 24, "Cr", "Chromium", "51.9961", "7.20", "1857", "2682", 'd', 3 , 105, 41},
78 { 7, 4, 25, "Mn", "Manganese", "54.938045", "7.44", "1246", "2062", 'd', 3 , 106, 42}, 78 { 7, 4, 25, "Mn", "Manganese", "54.938045", "7.44", "1246", "2062", 'd', 3 , 106, 42},
@@ -89,7 +89,7 @@ static const struct periodic_element_t periodic_elements[] = {
89 { 18, 4, 36, "Kr", "Krypton", "83.798", "3.733", "-156.6", "-153.35", 'p', 9 , 17, 53}, 89 { 18, 4, 36, "Kr", "Krypton", "83.798", "3.733", "-156.6", "-153.35", 'p', 9 , 17, 53},
90 { 1, 5, 37, "Rb", "Rubidium", "85.4678", "1.532", "38.89", "688", 's', 1 , 18, 54}, 90 { 1, 5, 37, "Rb", "Rubidium", "85.4678", "1.532", "38.89", "688", 's', 1 , 18, 54},
91 { 2, 5, 38, "Sr", "Strontium", "87.62", "2.54", "777", "1414", 's', 2 , 19, 55}, 91 { 2, 5, 38, "Sr", "Strontium", "87.62", "2.54", "777", "1414", 's', 2 , 19, 55},
92 { 3, 5, 39, "Y", "Yttrium", "88.90585", "4.469", "1520", "3388", 'd', 3 , 20, 20}, 92 { 3, 5, 39, "Y", "Yttrium", "88.90585", "4.469", "1520", "3388", 'd', 3 , 20, 70},
93 { 4, 5, 40, "Zr", "Zirconium", "91.224", "6.506", "1852", "4361", 'd', 3 , 21, 71}, 93 { 4, 5, 40, "Zr", "Zirconium", "91.224", "6.506", "1852", "4361", 'd', 3 , 21, 71},
94 { 5, 5, 41, "Nb", "Niobium", "92.90638", "8.57", "2477", "4744", 'd', 3 , 22, 72}, 94 { 5, 5, 41, "Nb", "Niobium", "92.90638", "8.57", "2477", "4744", 'd', 3 , 22, 72},
95 { 6, 5, 42, "Mo", "Molybdenum", "95.96", "10.22", "2623", "4682", 'd', 3 , 23, 73}, 95 { 6, 5, 42, "Mo", "Molybdenum", "95.96", "10.22", "2623", "4682", 'd', 3 , 23, 73},
@@ -121,7 +121,7 @@ static const struct periodic_element_t periodic_elements[] = {
121 { 13, 9, 68, "Er", "Erbium", "167.259", "9.066", "1529", "2868", 'f', 10 , 99, 99}, 121 { 13, 9, 68, "Er", "Erbium", "167.259", "9.066", "1529", "2868", 'f', 10 , 99, 99},
122 { 14, 9, 69, "Tm", "Thulium", "168.93421", "9.321", "1545", "1950", 'f', 10 , 100, 100}, 122 { 14, 9, 69, "Tm", "Thulium", "168.93421", "9.321", "1545", "1950", 'f', 10 , 100, 100},
123 { 15, 9, 70, "Yb", "Ytterbium", "173.054", "6.965", "819", "1196", 'f', 10 , 101, 101}, 123 { 15, 9, 70, "Yb", "Ytterbium", "173.054", "6.965", "819", "1196", 'f', 10 , 101, 101},
124 { 16, 9, 71, "Lu", "Lutetium", "174.9668", "9.840", "1663", "3402", 'f', 10 , 102, 102}, 124 { 16, 9, 71, "Lu", "Lutetium", "174.9668", "9.840", "1663", "3402", 'd', 10 , 38, 102},
125 { 4, 6, 72, "Hf", "Hafnium", "178.49", "13.31", "2233", "4603", 'd', 3 , 39, 103}, 125 { 4, 6, 72, "Hf", "Hafnium", "178.49", "13.31", "2233", "4603", 'd', 3 , 39, 103},
126 { 5, 6, 73, "Ta", "Tantalum", "180.94788", "16.654", "2985", "5510", 'd', 3 , 40, 104}, 126 { 5, 6, 73, "Ta", "Tantalum", "180.94788", "16.654", "2985", "5510", 'd', 3 , 40, 104},
127 { 6, 6, 74, "W", "Tungsten", "183.84", "19.3", "3407", "5555", 'd', 3 , 41, 105}, 127 { 6, 6, 74, "W", "Tungsten", "183.84", "19.3", "3407", "5555", 'd', 3 , 41, 105},
@@ -153,7 +153,7 @@ static const struct periodic_element_t periodic_elements[] = {
153 { 13, 10, 100, "Fm", "Fermium", "[257]", "-", "1527", "-", 'f', 11 , 67, 67}, 153 { 13, 10, 100, "Fm", "Fermium", "[257]", "-", "1527", "-", 'f', 11 , 67, 67},
154 { 14, 10, 101, "Md", "Mendelevium", "[258]", "-", "827", "-", 'f', 11 , 68, 68}, 154 { 14, 10, 101, "Md", "Mendelevium", "[258]", "-", "827", "-", 'f', 11 , 68, 68},
155 { 15, 10, 102, "No", "Nobelium", "[259]", "-", "827", "-", 'f', 11 , 69, 69}, 155 { 15, 10, 102, "No", "Nobelium", "[259]", "-", "827", "-", 'f', 11 , 69, 69},
156 { 16, 10, 103, "Lr", "Lawrencium", "[262]", "-", "1627", "-", 'f', 11 , 70, 70}, 156 { 16, 10, 103, "Lr", "Lawrencium", "[262]", "-", "1627", "-", 'f', 11 , 70, 20},
157 { 4, 7, 104, "Rf", "Rutherfordium", "[267]", "-", "-", "-", 'd', 3 , 71, 21}, 157 { 4, 7, 104, "Rf", "Rutherfordium", "[267]", "-", "-", "-", 'd', 3 , 71, 21},
158 { 5, 7, 105, "Db", "Dubnium", "[268]", "-", "-", "-", 'd', 3 , 72, 22}, 158 { 5, 7, 105, "Db", "Dubnium", "[268]", "-", "-", "-", 'd', 3 , 72, 22},
159 { 6, 7, 106, "Sg", "Seaborgium", "[271]", "-", "-", "-", 'd', 3 , 73, 23}, 159 { 6, 7, 106, "Sg", "Seaborgium", "[271]", "-", "-", "-", 'd', 3 , 73, 23},
@@ -162,11 +162,11 @@ static const struct periodic_element_t periodic_elements[] = {
162 { 9, 7, 109, "Mt", "Meitnerium", "[276]", "-", "-", "-", 'd', 3 , 76, 26}, 162 { 9, 7, 109, "Mt", "Meitnerium", "[276]", "-", "-", "-", 'd', 3 , 76, 26},
163 { 10, 7, 110, "Ds", "Darmstadtium", "[281]", "-", "-", "-", 'd', 3 , 77, 27}, 163 { 10, 7, 110, "Ds", "Darmstadtium", "[281]", "-", "-", "-", 'd', 3 , 77, 27},
164 { 11, 7, 111, "Rg", "Roentgenium", "[280]", "-", "-", "-", 'd', 3 , 78, 28}, 164 { 11, 7, 111, "Rg", "Roentgenium", "[280]", "-", "-", "-", 'd', 3 , 78, 28},
165 { 12, 7, 112, "Uub", "Ununbium", "[285]", "-", "-", "-", 'd', 3 , 79, 29}, 165 { 12, 7, 112, "Cn", "Copernicium", "[285]", "-", "-", "-", 'd', 3 , 79, 29},
166 { 13, 7, 113, "Uut", "Ununtrium", "[284]", "-", "-", "-", 'p', 4 , 80, 4}, 166 { 13, 7, 113, "Uut", "Ununtrium", "[284]", "-", "-", "-", 'p', 4 , 80, 4},
167 { 14, 7, 114, "Uuq", "Ununquadium", "[289]", "-", "-", "-", 'p', 4 , 81, 5}, 167 { 14, 7, 114, "Fl", "Flerovium", "[289]", "-", "-", "-", 'p', 4 , 81, 5},
168 { 15, 7, 115, "Uup", "Ununpentium", "[288]", "-", "-", "-", 'p', 4 , 82, 6}, 168 { 15, 7, 115, "Uup", "Ununpentium", "[288]", "-", "-", "-", 'p', 4 , 82, 6},
169 { 16, 7, 116, "Uuh", "Ununhexium", "[293]", "-", "-", "-", 'p', 4 , 83, 7}, 169 { 16, 7, 116, "Lv", "Livermorium", "[293]", "-", "-", "-", 'p', 4 , 83, 7},
170 { 17, 7, 117, "Uus", "Ununseptium", "[294]", "-", "-", "-", 'p', 4 , 84, 8}, 170 { 17, 7, 117, "Uus", "Ununseptium", "[294]", "-", "-", "-", 'p', 4 , 84, 8},
171 { 18, 7, 118, "Uuo", "Ununoctium", "[294]", "-", "-", "-", 'p', 9 , 85, 1} 171 { 18, 7, 118, "Uuo", "Ununoctium", "[294]", "-", "-", "-", 'p', 9 , 85, 1}
172}; 172};
@@ -271,15 +271,15 @@ static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
271 271
272 272
273/* - - - SOME CONSTANTS - - - */ 273/* - - - SOME CONSTANTS - - - */
274#if LCD_DEPTH > 1 274#ifdef HAVE_LCD_COLOR
275#define PERIODIC_COLOR_BLACK LCD_RGBPACK(0,0,0) 275#define PERIODIC_COLOR_BLACK LCD_RGBPACK(0,0,0)
276#elif LCD_DEPTH > 1 276#else
277#define PERIODIC_COLOR_BLACK LCD_BLACK 277#define PERIODIC_COLOR_BLACK LCD_BLACK
278#endif 278#endif
279 279
280#if LCD_DEPTH > 1 280#ifdef HAVE_LCD_COLOR
281#define PERIODIC_COLOR_WHITE LCD_RGBPACK(255,255,255) 281#define PERIODIC_COLOR_WHITE LCD_RGBPACK(255,255,255)
282#elif LCD_DEPTH > 1 282#else
283#define PERIODIC_COLOR_WHITE LCD_WHITE 283#define PERIODIC_COLOR_WHITE LCD_WHITE
284#endif 284#endif
285 285
@@ -293,7 +293,7 @@ static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
293 293
294static void periodic_makecols(void) 294static void periodic_makecols(void)
295{ 295{
296#if LCD_DEPTH > 1 296#ifdef HAVE_LCD_COLOR
297 int i = 0; 297 int i = 0;
298 298
299 periodic_color_palette[i++] = LCD_RGBPACK(255,255,255); /* 0 hydrogen */ 299 periodic_color_palette[i++] = LCD_RGBPACK(255,255,255); /* 0 hydrogen */
@@ -328,13 +328,14 @@ static void periodic_makecols(void)
328 328
329static int periodic_fix_period(int p) 329static int periodic_fix_period(int p)
330{ 330{
331 /* lanthanides/actinides are periods 9/10 in the internal chart, but make them look like 6/7 in the displayed table */ 331 /* lanthanides/actinides are periods 9/10 internally, but make them look like 6/7 in the displayed table */
332 return (p>8)?(p-3):p; 332 return (p>8)?(p-3):p;
333} 333}
334 334
335static int periodic_fix_group(int g, int p) 335static int periodic_fix_group(int g, int p)
336{ 336{
337 return (p>8)?0:g; 337 /* there is no agreed-upon group number for the lanthanides/actinides, but 3 is used sometimes */
338 return (p>8)?3:g;
338} 339}
339 340
340static char * periodic_group_name(int i) 341static char * periodic_group_name(int i)
@@ -488,16 +489,8 @@ static void periodic_draw(void)
488 rb->snprintf(buf, 40, "Name: %s", e.name); 489 rb->snprintf(buf, 40, "Name: %s", e.name);
489 rb->lcd_putsxy(nx, 0, buf); 490 rb->lcd_putsxy(nx, 0, buf);
490 491
491 /* don't show period number for lanthanides/actinides */ 492 rb->snprintf(buf, 40, "Group: %d %s", periodic_fix_group(e.group, e.period),
492 if(e.period<9) 493 periodic_group_name(periodic_sel));
493 {
494 rb->snprintf(buf, 40, "Group: %d %s", periodic_fix_group(e.group, e.period),
495 periodic_group_name(periodic_sel));
496 }
497 else
498 {
499 rb->snprintf(buf, 40, "Group: %s", periodic_group_name(periodic_sel));
500 }
501 rb->lcd_putsxy(nx, font_height, buf); 494 rb->lcd_putsxy(nx, font_height, buf);
502 495
503#else 496#else
@@ -632,36 +625,7 @@ enum plugin_status plugin_start(const void* parameter)
632 break; 625 break;
633 case PERIODIC_KEY_BACK: 626 case PERIODIC_KEY_BACK:
634 case PERIODIC_KEY_BACK_RPT: 627 case PERIODIC_KEY_BACK_RPT:
635 if(periodic_sel==103) 628 if (periodic_sel > 0)
636 {
637 periodic_sel=87;
638 }
639 else if(periodic_sel==88)
640 {
641 periodic_sel=38;
642 break;
643 }
644 else if(periodic_sel==56)
645 {
646 periodic_sel=20;
647 break;
648 }
649 else if(periodic_sel==71)
650 {
651 periodic_sel=55;
652 break;
653 }
654 else if(periodic_sel==39)
655 {
656 periodic_sel=102;
657 break;
658 }
659 else if(periodic_sel==21)
660 {
661 periodic_sel=70;
662 break;
663 }
664 else if (periodic_sel > 0)
665 { 629 {
666 periodic_sel--; 630 periodic_sel--;
667 } 631 }
@@ -672,37 +636,7 @@ enum plugin_status plugin_start(const void* parameter)
672 break; 636 break;
673 case PERIODIC_KEY_FORWARD: 637 case PERIODIC_KEY_FORWARD:
674 case PERIODIC_KEY_FORWARD_RPT: 638 case PERIODIC_KEY_FORWARD_RPT:
675 if(periodic_sel==102) 639 if (periodic_sel < ELEMENTS_COUNT - 1)
676 {
677 periodic_sel=39;
678 break;
679 }
680 else if(periodic_sel==87)
681 {
682 periodic_sel=103;
683 break;
684 }
685 else if(periodic_sel==70)
686 {
687 periodic_sel=21;
688 break;
689 }
690 else if(periodic_sel==55)
691 {
692 periodic_sel=71;
693 break;
694 }
695 else if(periodic_sel==38)
696 {
697 periodic_sel=88;
698 break;
699 }
700 else if(periodic_sel==20)
701 {
702 periodic_sel=56;
703 break;
704 }
705 else if (periodic_sel < ELEMENTS_COUNT - 1)
706 { 640 {
707 periodic_sel++; 641 periodic_sel++;
708 } 642 }