diff --git a/20231102/Makefile b/20231102/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7ae33df99f68fcf460324cfbb008f3f7a3863638 --- /dev/null +++ b/20231102/Makefile @@ -0,0 +1,8 @@ +%.elf: %.c + avr-gcc -Wall -Os -mmcu=atmega328p $< -o $@ + +%.hex: %.elf + avr-objcopy -O ihex $< $@ + +download: + ./download.sh diff --git a/20231102/answer.c b/20231102/answer.c new file mode 100644 index 0000000000000000000000000000000000000000..65a1dc248becb3157f2a226fc7b30df2ffb82e00 --- /dev/null +++ b/20231102/answer.c @@ -0,0 +1,6 @@ +#include "answer.h" + +int answer (void) +{ + return 23; +} diff --git a/20231102/answer.h b/20231102/answer.h new file mode 100644 index 0000000000000000000000000000000000000000..b6777e8210983d315b3ac3424a61bd9c9f0437b1 --- /dev/null +++ b/20231102/answer.h @@ -0,0 +1 @@ +extern int answer (void); diff --git a/20231102/bc-01.txt b/20231102/bc-01.txt new file mode 100644 index 0000000000000000000000000000000000000000..95ddcc5ac1fa4c2897a355e76e48292fadb46b29 --- /dev/null +++ b/20231102/bc-01.txt @@ -0,0 +1,19 @@ +cassini/home/peter/bo/2023ws/hp/20231102> bc +bc 1.07.1 +Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc. +This is free software with ABSOLUTELY NO WARRANTY. +For details type `warranty'. +obase=13 +6 * 9 +42 +obase=A +6 * 9 +54 +obase=13 +6 * 9 +42 +obase=1+1+1+1+1+1+1+1+1+1 +6 * 9 +54 + +cassini/home/peter/bo/2023ws/hp/20231102> diff --git a/20231102/bc-02.txt b/20231102/bc-02.txt new file mode 100644 index 0000000000000000000000000000000000000000..8d284a3fecea7f5da860653b20f1ed258e191a86 --- /dev/null +++ b/20231102/bc-02.txt @@ -0,0 +1,24 @@ +cassini/home/peter/bo/2023ws/hp/20231102> bc +bc 1.07.1 +Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc. +This is free software with ABSOLUTELY NO WARRANTY. +For details type `warranty'. +obase=16 +42 +2A +ibase=16 +B747 + A380 +15AC7 +obase=10 +5 + 5 +A +A + A +14 +18 + 18 +30 +ibase=1+1+1+1+1+1+1+1+1+1 +obase=10 +5 + 5 +10 + +cassini/home/peter/bo/2023ws/hp/20231102> diff --git a/20231102/bit-ops-01.c b/20231102/bit-ops-01.c new file mode 100644 index 0000000000000000000000000000000000000000..c4c79cf505ef40976260a85b2618d7d2e283dd52 --- /dev/null +++ b/20231102/bit-ops-01.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (void) +{ + printf ("2 & 2 = %d\n", 2 & 2); + return 0; +} diff --git a/20231102/bit-ops-02.c b/20231102/bit-ops-02.c new file mode 100644 index 0000000000000000000000000000000000000000..8c910ae16ba94684849cb02b95eb01229007f051 --- /dev/null +++ b/20231102/bit-ops-02.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (void) +{ + printf ("2^8 = %d\n", 2^8); + return 0; +} diff --git a/20231102/blink-0.c b/20231102/blink-0.c new file mode 100644 index 0000000000000000000000000000000000000000..b0022c681fd1482ed0a6d9fded7bb0a54699de32 --- /dev/null +++ b/20231102/blink-0.c @@ -0,0 +1,9 @@ +#include <avr/io.h> + +int main (void) +{ + DDRD = 0x40; /* binär: 0100 0000 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20231102/blink-0.hex b/20231102/blink-0.hex new file mode 100644 index 0000000000000000000000000000000000000000..6a05b7db67b71fe56b83474cab2ab278834e3777 --- /dev/null +++ b/20231102/blink-0.hex @@ -0,0 +1,10 @@ +:100000000C9434000C943E000C943E000C943E0082 +:100010000C943E000C943E000C943E000C943E0068 +:100020000C943E000C943E000C943E000C943E0058 +:100030000C943E000C943E000C943E000C943E0048 +:100040000C943E000C943E000C943E000C943E0038 +:100050000C943E000C943E000C943E000C943E0028 +:100060000C943E000C943E0011241FBECFEFD8E04C +:10007000DEBFCDBF0E9440000C9444000C940000F1 +:0C00800080E48AB98BB9FFCFF894FFCF61 +:00000001FF diff --git a/20231102/download.sh b/20231102/download.sh new file mode 100755 index 0000000000000000000000000000000000000000..770c3b5dca74ac09778be055c9d6f5adb0df293b --- /dev/null +++ b/20231102/download.sh @@ -0,0 +1,3 @@ +port=$(ls -rt /dev/ttyACM* | tail -1) +echo avrdude -P $port -c arduino -p m328p -U flash:w:$(ls -rt *.hex | tail -1) +avrdude -P $port -c arduino -p m328p -U flash:w:$(ls -rt *.hex | tail -1) 2>/dev/null diff --git a/20231102/gtk-01.c b/20231102/gtk-01.c new file mode 100644 index 0000000000000000000000000000000000000000..2cd0d601dee2293fdc361126ca08d208d7cdc1b9 --- /dev/null +++ b/20231102/gtk-01.c @@ -0,0 +1,17 @@ +#include <gtk/gtk.h> + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-01", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-01.txt b/20231102/gtk-01.txt new file mode 100644 index 0000000000000000000000000000000000000000..4b085004cd6889e4ef264a94f3f75a898b506b64 --- /dev/null +++ b/20231102/gtk-01.txt @@ -0,0 +1,52 @@ +cassini/home/peter/bo/2023ws/hp/20231102> gcc -Wall -O gtk-01.c -o gtk-01 +gtk-01.c:1:10: fatal error: gtk/gtk.h: Datei oder Verzeichnis nicht gefunden + 1 | #include <gtk/gtk.h> + | ^~~~~~~~~~~ +compilation terminated. +cassini/home/peter/bo/2023ws/hp/20231102> locate gtk/gtk.h +/usr/include/gtk-2.0/gtk/gtk.h +/usr/include/gtk-3.0/gtk/gtk.h +/usr/include/gtk-4.0/gtk/gtk.h +cassini/home/peter/bo/2023ws/hp/20231102> gcc -Wall -I /usr/include/gtk-4.0 -O gtk-01.c -o gtk-01 +In file included from /usr/include/gtk-4.0/gtk/gtk.h:30, + from gtk-01.c:1: +/usr/include/gtk-4.0/gtk/css/gtkcss.h:30:10: fatal error: glib.h: Datei oder Verzeichnis nicht gefunden + 30 | #include <glib.h> + | ^~~~~~~~ +compilation terminated. +cassini/home/peter/bo/2023ws/hp/20231102> locate glib.h +/home/peter/bo/2012ws/rtech/material/usbstick/fdos/source/command/command/suppl/msglib.h +/usr/include/jpeglib.h +/usr/include/dbus-1.0/dbus/dbus-glib.h +/usr/include/glib-2.0/glib.h +/usr/include/harfbuzz/hb-glib.h +cassini/home/peter/bo/2023ws/hp/20231102> gcc -Wall -I /usr/include/gtk-4.0 -I /usr/include/glib-2.0 -O gtk-01.c -o gtk-01 +In file included from /usr/include/glib-2.0/glib/galloca.h:34, + from /usr/include/glib-2.0/glib.h:32, + from /usr/include/gtk-4.0/gtk/css/gtkcss.h:30, + from /usr/include/gtk-4.0/gtk/gtk.h:30, + from gtk-01.c:1: +/usr/include/glib-2.0/glib/gtypes.h:34:10: fatal error: glibconfig.h: Datei oder Verzeichnis nicht gefunden + 34 | #include <glibconfig.h> + | ^~~~~~~~~~~~~~ +compilation terminated. +cassini/home/peter/bo/2023ws/hp/20231102> pkg-config --cflags --libs gtk4 +-I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 +cassini/home/peter/bo/2023ws/hp/20231102> gcc -Wall -O -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 gtk-01.c -o gtk-01 +/usr/bin/ld: /tmp/cc6S8nDW.o: in function `activate': +gtk-01.c:(.text+0x7): undefined reference to `gtk_application_window_new' +/usr/bin/ld: gtk-01.c:(.text+0xf): undefined reference to `gtk_window_get_type' +/usr/bin/ld: gtk-01.c:(.text+0x1d): undefined reference to `g_type_check_instance_cast' +/usr/bin/ld: gtk-01.c:(.text+0x2c): undefined reference to `gtk_window_set_title' +/usr/bin/ld: gtk-01.c:(.text+0x37): undefined reference to `g_type_check_instance_cast' +/usr/bin/ld: gtk-01.c:(.text+0x3f): undefined reference to `gtk_window_present' +/usr/bin/ld: /tmp/cc6S8nDW.o: in function `main': +gtk-01.c:(.text+0x60): undefined reference to `gtk_application_new' +/usr/bin/ld: gtk-01.c:(.text+0x8a): undefined reference to `g_signal_connect_data' +/usr/bin/ld: gtk-01.c:(.text+0x8f): undefined reference to `g_application_get_type' +/usr/bin/ld: gtk-01.c:(.text+0x9a): undefined reference to `g_type_check_instance_cast' +/usr/bin/ld: gtk-01.c:(.text+0xa7): undefined reference to `g_application_run' +/usr/bin/ld: gtk-01.c:(.text+0xb1): undefined reference to `g_object_unref' +collect2: error: ld returned 1 exit status +cassini/home/peter/bo/2023ws/hp/20231102> gcc -Wall -O gtk-01.c -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -o gtk-01 +cassini/home/peter/bo/2023ws/hp/20231102> diff --git a/20231102/gtk-01a.c b/20231102/gtk-01a.c new file mode 100644 index 0000000000000000000000000000000000000000..d703f0e77abe1537808ccfef816602727b4fc0b1 --- /dev/null +++ b/20231102/gtk-01a.c @@ -0,0 +1,10 @@ +#include <gtk/gtk.h> + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-01", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-01b.c b/20231102/gtk-01b.c new file mode 100644 index 0000000000000000000000000000000000000000..92cc3d65ed0c53c367b23acefb2ed5395f294231 --- /dev/null +++ b/20231102/gtk-01b.c @@ -0,0 +1,19 @@ +#include <gtk/gtk.h> +#include <stdio.h> + +static void activate (GtkApplication *app, gpointer user_data) +{ + printf ("activate()\n"); + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-01", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-01c.c b/20231102/gtk-01c.c new file mode 100644 index 0000000000000000000000000000000000000000..51961e429b7af4545e409484dd06e4c6f8196783 --- /dev/null +++ b/20231102/gtk-01c.c @@ -0,0 +1,22 @@ +#include <gtk/gtk.h> +#include <stdio.h> + +static void activate (GtkApplication *app, gpointer user_data) +{ + printf ("activate()\n"); + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-01", G_APPLICATION_DEFAULT_FLAGS); + printf ("vor g_signal_connect()\n"); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + printf ("vor g_application_run()\n"); + int status = g_application_run (G_APPLICATION (app), argc, argv); + printf ("nach g_application_run()\n"); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-02.c b/20231102/gtk-02.c new file mode 100644 index 0000000000000000000000000000000000000000..1ab3c19ea31e2c4a7960937bb97509bb0ad9ecdd --- /dev/null +++ b/20231102/gtk-02.c @@ -0,0 +1,27 @@ +#include <gtk/gtk.h> +#include <stdio.h> + +static void hello (GtkWidget *this, gpointer user_data) +{ + char *world = user_data; + printf ("Hello, %s!\n", world); +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + GtkWidget *button = gtk_button_new_with_label ("Hello, world!"); + g_signal_connect (button, "clicked", G_CALLBACK (hello), "world"); + gtk_window_set_child (GTK_WINDOW (window), button); + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.gtk-02", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-03.c b/20231102/gtk-03.c new file mode 100644 index 0000000000000000000000000000000000000000..4fe3a030783bc3075bae4a85705085d0e36b8d5c --- /dev/null +++ b/20231102/gtk-03.c @@ -0,0 +1,26 @@ +#include <gtk/gtk.h> + +static void close_window (GtkWidget *this, gpointer user_data) +{ + GtkWindow *window = user_data; + gtk_window_destroy (window); +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + GtkWidget *button = gtk_button_new_with_label ("Quit"); + g_signal_connect (button, "clicked", G_CALLBACK (close_window), window); + gtk_window_set_child (GTK_WINDOW (window), button); + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-04.c b/20231102/gtk-04.c new file mode 100644 index 0000000000000000000000000000000000000000..6ae0e7dca8ad959bcf22fb275d6a78a5f39c00f5 --- /dev/null +++ b/20231102/gtk-04.c @@ -0,0 +1,20 @@ +#include <gtk/gtk.h> + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + GtkWidget *button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_window_set_child (GTK_WINDOW (window), button); + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-05.c b/20231102/gtk-05.c new file mode 100644 index 0000000000000000000000000000000000000000..a7394ee1faf9c92fe04a7ca5e95b79a63d9c3b66 --- /dev/null +++ b/20231102/gtk-05.c @@ -0,0 +1,35 @@ +#include <gtk/gtk.h> + +static void hello (GtkWidget *this, gpointer user_data) +{ + char *world = user_data; + printf ("Hello, %s!\n", world); +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *hello_button = gtk_button_new_with_label ("Hello, world!"); + g_signal_connect (hello_button, "clicked", G_CALLBACK (hello), "world"); + gtk_box_append (GTK_BOX (vbox), hello_button); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-06.c b/20231102/gtk-06.c new file mode 100644 index 0000000000000000000000000000000000000000..64687de0440a694d1f644de4f2a180a37987ff84 --- /dev/null +++ b/20231102/gtk-06.c @@ -0,0 +1,53 @@ +#include <gtk/gtk.h> + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA red = { 1.0, 0.0, 0.0, 0.8 }; + GdkRGBA yellow = { 1.0, 1.0, 0.0, 0.6 }; + GdkRGBA blue = { 0.0, 0.5, 1.0, 0.4 }; + + gdk_cairo_set_source_rgba (c, &red); + cairo_rectangle (c, 10, 10, 60, 40); + cairo_fill (c); + + gdk_cairo_set_source_rgba (c, &yellow); + cairo_arc (c, 65, 50, 30, 0, 2 * G_PI); + cairo_fill (c); + + gdk_cairo_set_source_rgba (c, &blue); + cairo_move_to (c, 10, 70); + cairo_line_to (c, 70, 70); + cairo_line_to (c, 40, 18); + cairo_close_path (c); + cairo_fill (c); +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, 100, 100); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/gtk-06a.c b/20231102/gtk-06a.c new file mode 100644 index 0000000000000000000000000000000000000000..46e02a52785486fc64d2261cb4889cface90b3ac --- /dev/null +++ b/20231102/gtk-06a.c @@ -0,0 +1,55 @@ +#include <gtk/gtk.h> + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + printf ("draw()\n"); + + GdkRGBA red = { 1.0, 0.0, 0.0, 0.8 }; + GdkRGBA yellow = { 1.0, 1.0, 0.0, 0.6 }; + GdkRGBA blue = { 0.0, 0.5, 1.0, 0.4 }; + + gdk_cairo_set_source_rgba (c, &red); + cairo_rectangle (c, 10, 10, 60, 40); + cairo_fill (c); + + gdk_cairo_set_source_rgba (c, &yellow); + cairo_arc (c, 65, 50, 30, 0, 2 * G_PI); + cairo_fill (c); + + gdk_cairo_set_source_rgba (c, &blue); + cairo_move_to (c, 10, 70); + cairo_line_to (c, 70, 70); + cairo_line_to (c, 40, 18); + cairo_close_path (c); + cairo_fill (c); +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, 100, 100); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + return status; +} diff --git a/20231102/hp-20231102.txt b/20231102/hp-20231102.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b7825a69284a0876614da66326020db0e82846a --- /dev/null +++ b/20231102/hp-20231102.txt @@ -0,0 +1,35 @@ +"Output" +~~~~~~~~ +AND + 10101100 A + & 11111011 Bit gezielt löschen & B "Maske" + -------- --- + 10101000 A, außer dort, wo B Nullen hat + Dort sind es Nullen. +OR + 10101100 A + | 00000010 Bit gezielt setzen & B "Maske" + -------- --- + 10101110 A, außer dort, wo B Einsen hat + Dort sind es Einsen. +XOR + 10101100 A + ^ 00000010 Bit gezielt umklappen & B "Maske" + -------- --- + 10101110 A, außer dort, wo B Einsen hat + Dort wird A umgeklappt. + 00000010 + ^ 00001000 + -------- + 00001010 + +"Input" +~~~~~~~ +AND + 10101100 + & 00000100 + -------- + 00000100 <-- ungleich 0: Bit war gesetzt + + Achtung: Das Ergebnis ist nicht gleich 1! + (sondern: gleich 4) diff --git a/20231102/inttypes-01.c b/20231102/inttypes-01.c new file mode 100644 index 0000000000000000000000000000000000000000..199cc8c7fde8362918a296a1dba592e1f9b48b11 --- /dev/null +++ b/20231102/inttypes-01.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + uint64_t a = 2^14; + printf ("a = %d\n", a); + return 0; +} diff --git a/20231102/inttypes-02.c b/20231102/inttypes-02.c new file mode 100644 index 0000000000000000000000000000000000000000..db5f57ac4a2bf412a48344b229acacc25634af6d --- /dev/null +++ b/20231102/inttypes-02.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + uint64_t a = 2^14; + printf ("a = %ld\n", a); + return 0; +} diff --git a/20231102/inttypes-03.c b/20231102/inttypes-03.c new file mode 100644 index 0000000000000000000000000000000000000000..75106270555681b2a3edd428f3a995fd279e7286 --- /dev/null +++ b/20231102/inttypes-03.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <stdint.h> +#include <inttypes.h> + +int main (void) +{ + uint64_t a = 2^14; + printf ("a = %" PRIu64 "\n", a); + return 0; +} diff --git a/20231102/libraries-01.txt b/20231102/libraries-01.txt new file mode 100644 index 0000000000000000000000000000000000000000..a62d99c83018145522912641729418ab20a5802b --- /dev/null +++ b/20231102/libraries-01.txt @@ -0,0 +1,10 @@ +cassini/home/peter/bo/2023ws/hp/20231102> ar rs libanswer.a answer.o +ar: creating libanswer.a +cassini/home/peter/bo/2023ws/hp/20231102> ls -l libanswer.a +-rw-r--r-- 1 peter peter 1232 2. Nov 14:45 libanswer.a +cassini/home/peter/bo/2023ws/hp/20231102> gcc -Wall -O philosophy.c -lanswer -o philosophy /usr/bin/ld: cannot find -lanswer: Datei oder Verzeichnis nicht gefunden +collect2: error: ld returned 1 exit status +cassini/home/peter/bo/2023ws/hp/20231102> gcc -L . -Wall -O philosophy.c -lanswer -o philosophy +cassini/home/peter/bo/2023ws/hp/20231102> ./philosophy +The answer is 23. +cassini/home/peter/bo/2023ws/hp/20231102> diff --git a/20231102/number-systems-01.c b/20231102/number-systems-01.c new file mode 100644 index 0000000000000000000000000000000000000000..791b2f4b6cfc9c6157d465fba5c61bd0b3bc53ea --- /dev/null +++ b/20231102/number-systems-01.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + int number[] = { 01, 02, 03, 04, 05, 06, 07, 08, 09, 10 }; // Achtung: Oktalzahlen! + for (int i = 0; i < 10; i++) + printf ("%d\n", number[i]); + return 0; +} diff --git a/20231102/number-systems-02.c b/20231102/number-systems-02.c new file mode 100644 index 0000000000000000000000000000000000000000..958ef95972c64d316bf04129b7e43b4e95b334ef --- /dev/null +++ b/20231102/number-systems-02.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main (void) +{ + int number[] = { 023, 025, 027, // Achtung: Oktalzahlen! + 033, 035, 037, + 123, 125, 127, + 133, 135, 137 }; + for (int i = 0; i < 12; i++) + printf ("%d\n", number[i]); + return 0; +} diff --git a/20231102/philosophy.c b/20231102/philosophy.c new file mode 100644 index 0000000000000000000000000000000000000000..e9f508a501d9ec66d02e0636a9f6c71f2c7a8594 --- /dev/null +++ b/20231102/philosophy.c @@ -0,0 +1,8 @@ +#include <stdio.h> +#include "answer.h" + +int main (void) +{ + printf ("The answer is %d.\n", answer ()); + return 0; +}