Skip to content
Snippets Groups Projects
Commit a1957e1b authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiele und Screenshots 2.11.2023

parent 44ca4827
Branches 2014ss
No related tags found
No related merge requests found
Showing with 375 additions and 0 deletions
%.elf: %.c
avr-gcc -Wall -Os -mmcu=atmega328p $< -o $@
%.hex: %.elf
avr-objcopy -O ihex $< $@
download:
./download.sh
#include "answer.h"
int answer (void)
{
return 23;
}
extern int answer (void);
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>
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>
#include <stdio.h>
int main (void)
{
printf ("2 & 2 = %d\n", 2 & 2);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("2^8 = %d\n", 2^8);
return 0;
}
#include <avr/io.h>
int main (void)
{
DDRD = 0x40; /* binär: 0100 0000 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
:100000000C9434000C943E000C943E000C943E0082
:100010000C943E000C943E000C943E000C943E0068
:100020000C943E000C943E000C943E000C943E0058
:100030000C943E000C943E000C943E000C943E0048
:100040000C943E000C943E000C943E000C943E0038
:100050000C943E000C943E000C943E000C943E0028
:100060000C943E000C943E0011241FBECFEFD8E04C
:10007000DEBFCDBF0E9440000C9444000C940000F1
:0C00800080E48AB98BB9FFCFF894FFCF61
:00000001FF
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
#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;
}
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>
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment