summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-07-24 16:18:13 +0930
committerDaniel Jones <admin@danieljon.es>2020-07-24 16:18:13 +0930
commit58118770e0dd3de973d4b9e5e6e52c0bf520ff9c (patch)
tree211fcd0e2619e8e3a5d2d8166ca0e2d48b6008c4
parent3a429d84c0e38b4a33834400aa0213082b634d55 (diff)
downloadfoxlogicgates-master.tar.gz
foxlogicgates-master.zip
added pulse, project on holdHEADmaster
-rw-r--r--Gate.cpp7
-rw-r--r--Gate.h1
-rw-r--r--MainWindow.cpp30
-rw-r--r--MainWindow.h6
-rw-r--r--icons.h26
5 files changed, 68 insertions, 2 deletions
diff --git a/Gate.cpp b/Gate.cpp
index 33313f3..5ebec86 100644
--- a/Gate.cpp
+++ b/Gate.cpp
@@ -73,6 +73,13 @@ void Gate::update_state()
break;
}
+ case PULSE:
+ {
+ if (output_state)
+ output_state = false;
+ break;
+ }
+
case OUTPUT:
{
if (input_gate1 && input_gate1->get_output_state() == true)
diff --git a/Gate.h b/Gate.h
index 6519791..0ee833d 100644
--- a/Gate.h
+++ b/Gate.h
@@ -36,6 +36,7 @@ class Gate : public Object
XOR,
XNOR,
NAND3,
+ PULSE,
};
Gate(GATE_TYPE type = INPUT, int x = 0, int y = 0, int width = 70, int height = 50, int id = -1);
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 72a53d7..a738b26 100644
--- a/MainWindow.cpp
+++ b/MainWindow.cpp
@@ -30,6 +30,7 @@ FXDEFMAP(MainWindow) MainWindow_Map[]=
FXMAPFUNC(SEL_KEYRELEASE, 0, MainWindow::on_key_release),
/* toolbox */
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_BUTTON_INPUT, MainWindow::input_button_press),
+ FXMAPFUNC(SEL_COMMAND, MainWindow::ID_BUTTON_PULSE, MainWindow::pulse_button_press),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_BUTTON_OUTPUT, MainWindow::output_button_press),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_BUTTON_AND, MainWindow::and_button_press),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_BUTTON_NAND, MainWindow::nand_button_press),
@@ -71,6 +72,7 @@ MainWindow::create()
{
FXMainWindow::create();
INPUT_icon->create();
+ PULSE_icon->create();
OUTPUT_icon->create();
AND_icon->create();
NAND_icon->create();
@@ -94,6 +96,7 @@ MainWindow::create_ui()
/* icons */
INPUT_icon = new FXGIFIcon(app, INPUT_icon_data, IMAGE_KEEP);
+ PULSE_icon = new FXGIFIcon(app, PULSE_icon_data, IMAGE_KEEP);
OUTPUT_icon = new FXGIFIcon(app, OUTPUT_icon_data, IMAGE_KEEP);
AND_icon = new FXGIFIcon(app, AND_icon_data, IMAGE_KEEP);
NAND_icon = new FXGIFIcon(app, NAND_icon_data, IMAGE_KEEP);
@@ -112,6 +115,7 @@ MainWindow::create_ui()
new FXLabel(toolsFrame, "Toolbox", NULL, JUSTIFY_CENTER_X|LAYOUT_FILL_X);
new FXHorizontalSeparator(toolsFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X);
new FXButton(toolsFrame, "", INPUT_icon, this, MainWindow::ID_BUTTON_INPUT, BUTTON_NORMAL|LAYOUT_FILL_X);
+ new FXButton(toolsFrame, "", PULSE_icon, this, MainWindow::ID_BUTTON_PULSE, BUTTON_NORMAL|LAYOUT_FILL_X);
new FXButton(toolsFrame, "", OUTPUT_icon, this, MainWindow::ID_BUTTON_OUTPUT, BUTTON_NORMAL|LAYOUT_FILL_X);
new FXButton(toolsFrame, "AND", AND_icon, this, MainWindow::ID_BUTTON_AND, BUTTON_NORMAL|LAYOUT_FILL_X);
new FXButton(toolsFrame, "NAND", NAND_icon, this, MainWindow::ID_BUTTON_NAND, BUTTON_NORMAL|LAYOUT_FILL_X);
@@ -203,6 +207,20 @@ MainWindow::draw()
break;
}
+ case Gate::PULSE:
+ {
+ if (gate1->get_output_state() == true)
+ {
+ /* input is switched on, indicate so */
+ dc_image.setForeground(FXRGB(255, 255, 0));
+ dc_image.fillRectangle(gate1->get_x(), gate1->get_y(), gate1->get_width(), gate1->get_height());
+ dc_image.setForeground(FXRGB(0,0,0));
+ }
+ dc_image.drawIcon(PULSE_icon, gate1->get_x(), gate1->get_y());
+ break;
+ }
+
+
case Gate::OUTPUT:
{
if (gate1->get_output_state() == true)
@@ -1402,7 +1420,7 @@ MainWindow::on_right_mouse_down(FXObject*, FXSelector, void *ptr)
case Object::GATE:
{
Gate *gate = (Gate*)object;
- if (gate->get_gate_type() == Gate::INPUT)
+ if (gate->get_gate_type() == Gate::INPUT || gate->get_gate_type() == Gate::PULSE)
{
/* toggle state */
gate->set_state(!gate->get_output_state());
@@ -1576,6 +1594,16 @@ MainWindow::input_button_press(FXObject *sender, FXSelector sel, void *ptr)
}
long
+MainWindow::pulse_button_press(FXObject *sender, FXSelector sel, void *ptr)
+{
+ selected_object = nullptr;
+ selected_object_type = Object::GATE;
+ selected_gate_type = Gate::PULSE;
+ return 1;
+}
+
+
+long
MainWindow::output_button_press(FXObject *sender, FXSelector sel, void *ptr)
{
selected_object = nullptr;
diff --git a/MainWindow.h b/MainWindow.h
index a443e71..b7dd4de 100644
--- a/MainWindow.h
+++ b/MainWindow.h
@@ -53,6 +53,7 @@ class MainWindow : public FXMainWindow
enum {
ID_CANVAS = FXMainWindow::ID_LAST,
ID_BUTTON_INPUT,
+ ID_BUTTON_PULSE,
ID_BUTTON_OUTPUT,
ID_BUTTON_AND,
ID_BUTTON_NAND,
@@ -80,6 +81,7 @@ class MainWindow : public FXMainWindow
long on_mouse_move(FXObject*,FXSelector,void* ptr);
/* toolbox */
long input_button_press(FXObject*,FXSelector,void* ptr);
+ long pulse_button_press(FXObject*,FXSelector,void* ptr);
long output_button_press(FXObject*,FXSelector,void* ptr);
long and_button_press(FXObject*,FXSelector,void* ptr);
long nand_button_press(FXObject*,FXSelector,void* ptr);
@@ -153,6 +155,7 @@ class MainWindow : public FXMainWindow
/* icons */
FXGIFIcon *INPUT_icon;
FXGIFIcon *OUTPUT_icon;
+ FXGIFIcon *PULSE_icon;
FXGIFIcon *AND_icon;
FXGIFIcon *NAND_icon;
FXGIFIcon *NAND3_icon;
@@ -165,6 +168,7 @@ class MainWindow : public FXMainWindow
/* buttons */
FXButton *INPUT_button;
+ FXButton *PULSE_button;
FXButton *OUTPUT_button;
FXButton *AND_button;
FXButton *NAND_button;
@@ -221,7 +225,7 @@ class Thread : public FXThread
{
while (1)
{
- FXThread::sleep(70000000);
+ FXThread::sleep(40000000);
sig->signal();
};
return 0;
diff --git a/icons.h b/icons.h
index 8fad1db..f3ce55f 100644
--- a/icons.h
+++ b/icons.h
@@ -199,6 +199,32 @@ const unsigned char OUTPUT_icon_data[]={
0x02,0x00,0x3b
};
+/* created by reswrap from file icons/PULSE_icon_data.gif */
+const unsigned char PULSE_icon_data[]={
+ 0x47,0x49,0x46,0x38,0x39,0x61,0x46,0x00,0x32,0x00,0x80,0x01,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0x21,0xfe,0x26,0x4d,0x61,0x64,0x65,0x20,0x66,0x6f,0x72,0x20,0x66,
+ 0x6f,0x78,0x6c,0x6f,0x67,0x69,0x63,0x67,0x61,0x74,0x65,0x73,0x20,0x62,0x79,0x20,
+ 0x44,0x61,0x6e,0x69,0x65,0x6c,0x20,0x4a,0x6f,0x6e,0x65,0x73,0x00,0x21,0xf9,0x04,
+ 0x01,0x0a,0x00,0x01,0x00,0x2c,0x00,0x00,0x00,0x00,0x46,0x00,0x32,0x00,0x00,0x02,
+ 0xfe,0x8c,0x8f,0xa9,0xcb,0xed,0x0f,0xa3,0x9c,0xb4,0xda,0x8b,0x0d,0xd8,0xbc,0xfb,
+ 0x0f,0x86,0xe2,0xb8,0x45,0xe4,0x89,0xa6,0xa0,0x09,0x64,0x6e,0xc3,0xb1,0xef,0x9c,
+ 0xc4,0x50,0x49,0xe7,0xf6,0x83,0xe7,0xf3,0xee,0xe8,0xf9,0x5c,0x40,0x58,0x6b,0xf8,
+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by reswrap from file icons/XNOR_icon_data.gif */
const unsigned char XNOR_icon_data[]={
0x47,0x49,0x46,0x38,0x39,0x61,0x46,0x00,0x32,0x00,0x80,0x01,0x00,0x00,0x00,0x00,