Canola
0.8.D001
|
00001 // 00002 // canola - canon canola 1614p emulator 00003 // Copyright (C) 2011, 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License, version 3, as 00007 // published by the Free Software Foundation. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License along 00015 // with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #include <canola/nixie_tube.h> 00019 #include <canola/load_image.h> 00020 00021 00022 nixie_tube::~nixie_tube() 00023 { 00024 } 00025 00026 00027 nixie_tube::nixie_tube() : 00028 pos_number(0) 00029 { 00030 if (!digit_images[0]) 00031 load_images(); 00032 00033 attach(pos, 0, 1, 0, 1); 00034 attach(tick, 1, 2, 0, 1); 00035 attach(digit, 0, 1, 1, 2); 00036 attach(dot, 1, 2, 1, 2); 00037 attach(bezlo, 0, 2, 2, 3); 00038 00039 pos.set(pos_images[0]); 00040 tick.set(tick_images[0]); 00041 dot.set(dot_images[0]); 00042 digit.set(digit_images[10]); 00043 bezlo.set(bezlo_image); 00044 } 00045 00046 00047 void 00048 nixie_tube::load_images(void) 00049 { 00050 digit_images[0] = load_gui_image("nixie-tube-32-digit-0"); 00051 digit_images[1] = load_gui_image("nixie-tube-32-digit-1"); 00052 digit_images[2] = load_gui_image("nixie-tube-32-digit-2"); 00053 digit_images[3] = load_gui_image("nixie-tube-32-digit-3"); 00054 digit_images[4] = load_gui_image("nixie-tube-32-digit-4"); 00055 digit_images[5] = load_gui_image("nixie-tube-32-digit-5"); 00056 digit_images[6] = load_gui_image("nixie-tube-32-digit-6"); 00057 digit_images[7] = load_gui_image("nixie-tube-32-digit-7"); 00058 digit_images[8] = load_gui_image("nixie-tube-32-digit-8"); 00059 digit_images[9] = load_gui_image("nixie-tube-32-digit-9"); 00060 digit_images[10] = load_gui_image("nixie-tube-32-digit-off"); 00061 00062 dot_images[0] = load_gui_image("nixie-tube-32-dot-off"); 00063 dot_images[1] = load_gui_image("nixie-tube-32-dot-on"); 00064 00065 tick_images[0] = load_gui_image("nixie-tube-32-tick-blank"); 00066 tick_images[1] = load_gui_image("nixie-tube-32-tick-off"); 00067 tick_images[2] = load_gui_image("nixie-tube-32-tick-on"); 00068 00069 pos_images[0] = load_gui_image("nixie-tube-32-pos-00"); 00070 pos_images[1] = load_gui_image("nixie-tube-32-pos-01"); 00071 pos_images[2] = load_gui_image("nixie-tube-32-pos-02"); 00072 pos_images[3] = load_gui_image("nixie-tube-32-pos-03"); 00073 pos_images[4] = load_gui_image("nixie-tube-32-pos-04"); 00074 pos_images[5] = load_gui_image("nixie-tube-32-pos-05"); 00075 pos_images[6] = load_gui_image("nixie-tube-32-pos-06"); 00076 pos_images[7] = load_gui_image("nixie-tube-32-pos-07"); 00077 pos_images[8] = load_gui_image("nixie-tube-32-pos-08"); 00078 pos_images[9] = load_gui_image("nixie-tube-32-pos-09"); 00079 pos_images[10] = load_gui_image("nixie-tube-32-pos-10"); 00080 pos_images[11] = load_gui_image("nixie-tube-32-pos-11"); 00081 pos_images[12] = load_gui_image("nixie-tube-32-pos-12"); 00082 pos_images[13] = load_gui_image("nixie-tube-32-pos-13"); 00083 pos_images[14] = load_gui_image("nixie-tube-32-pos-14"); 00084 pos_images[15] = load_gui_image("nixie-tube-32-pos-15"); 00085 pos_images[16] = load_gui_image("nixie-tube-32-pos-16"); 00086 00087 bezlo_image = load_gui_image("nixie-tube-32-bezel-lo"); 00088 } 00089 00090 00091 void 00092 nixie_tube::set_number(int n) 00093 { 00094 if (n < 0 || n > 16) 00095 n = 0; 00096 pos_number = n; 00097 pos.set(pos_images[pos_number]); 00098 } 00099 00100 00101 void 00102 nixie_tube::set_value(const display::tube_t &value) 00103 { 00104 if (value.digit >= 0 && value.digit <= 9) 00105 digit.set(digit_images[value.digit]); 00106 else 00107 digit.set(digit_images[10]); 00108 dot.set(dot_images[0 + value.dot]); 00109 if (pos_number <= 1 && !value.tick) 00110 tick.set(tick_images[0]); 00111 else 00112 tick.set(tick_images[1 + value.tick]); 00113 }