*Dear friends. I am born in 1936 and therefor i learn slowly !!!!! HI HI*
*I have made a little program in c using terminal. This program is working
and i must say i am a litle prowed hi hi*
*I have made an emty window with gtk but but How shall i put my input in
this window ???*
*Must say thats difficult for me to understand *
*#include <gtk/gtk.h>*
*int*
*main (int argc,*
* char *argv[])*
*{*
* GtkWidget *window;*
* /* Initialise GTK+ passing to it all command line arguments */*
* gtk_init (&argc, &argv);*
* /* create a new window, set values */*
* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);*
* gtk_window_set_title (GTK_WINDOW (window), "Dette er bare et tomt
vindue");*
* /* set the size of the window */*
* gtk_widget_set_size_request (GTK_WIDGET (window), 200, 200);*
* /* connect the windows "destroy" event */*
* g_signal_connect (G_OBJECT (window), "destroy",*
* G_CALLBACK (gtk_main_quit), NULL); *
* /* set the window as visible */*
* gtk_widget_show (window);*
* /* run the GTK+ main loop */*
* gtk_main ();*
* return 0;*
*}*
*This program here can i compile and i can se an emty window but how do i
make input with my terminal program ?? I am radioamateur and have made this
program for my terminal*
*writing gcc freq.c -o freq i get following skærmbillede fra 2015-03-26
12:19:21.png*
*ole@ole1:~/Skrivebord$ gcc freq.c -o freqole@ole1:~/Skrivebord$ sudo
./freq[sudo] password for ole: Program Started-Port openPortout=
128------Press:"f" - to input frequency,"q" - to exit
program,<space> - to toggle transmitterfInput frequency as 144.000 in Step
25KHz.: 144.625Portout= 153------You se144.000 = portoutput
128 144.625=portoutput 153 146.000=portoutput 20880 channels every 25000
HZ This program want i working with gtk HOWCan i get some hints
???????????????? I will be very very gladI hope somebody can help me Happy
Easter from Ole OZ6OH radioamateur in Denmark [email protected]
<[email protected]>*
//program sourcenavn er gg.c
#include <stdio.h>//In use
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>// In use
#include <sys/io.h>//In use
#define base 0x378 /*Here is Port defined*/
float x = 144.000;
int value = 0;
int s = 0x01;
int kbhit(void)
{
struct termios oldt, newt;
int ch;
int oldf;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
fcntl(STDIN_FILENO, F_SETFL, oldf);
if(ch != EOF)
{
ungetc(ch, stdin);
return 1;
}
return 0;
}
int int_round(double n) // Round n
{
return (n > 0.0) ? (n + 0.5) : (n -0.5);
}
void setfrq() {
if ((x>=144.000) && (x<=146.000)) {
value = int_round((x - 140.8) * 40.0); /* Calculation */
printf("\nPortout= %d", value); /* Show Output on Led's */
outb(value, base);
} else printf("\nInvalid input.");
}
void getfrq() {
outb(0x01, base+2);
printf("\nInput frequency as 144.000 in Step 25KHz.: ");
scanf("%f",&x);
setfrq();
}
void togg_tx() {
if (s==0x01) s=0x00; else s=0x01;
char c = (char) (s+48);
printf("\nStrobe=%c",c);
outb(s, base+2);
}
void initmsg() {
printf("\n------\nPress:");
printf("\n\"f\" - to input frequency,");
printf("\n\"q\" - to exit program,");
printf("\n<space> - to toggle transmitter");
}
main(int argc, char **argv)
{
// Main starting here
printf("\nProgram Started-");
if (ioperm(base, 3, 1)) { perror("ioperm"); printf("\nError"); exit(1); } // Use sudo !
printf("\nPort open");
outb(s, base+2);
setfrq();
initmsg();
while(1)
{
if (kbhit()) {
char ch = getchar();
if ((ch == 'Q') || (ch == 'q')) {
outb(0x01, base+2);
printf("\nProgram Terminated.");
exit(0);
}
if ((ch == 'F') || (ch == 'f')) getfrq();
if (ch == ' ') togg_tx();
initmsg();
}
usleep(500);
}
}
_______________________________________________
gnome-doc-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-doc-list