示例#1
0
文件: a_lib.c 项目: rballis/up4dar-os
static void set_speaker_volume (int up)
{
	int new_volume = SETTING_CHAR(C_SPKR_VOLUME) + ( up ? 1 : -1 );
	
	if ((new_volume <= 6) && (new_volume >= -57))
	{
		SETTING_CHAR(C_SPKR_VOLUME) = new_volume;
		
		char buf[4];
		
		if (new_volume < 0)
		{
			new_volume = -new_volume;
			buf[0] = '-';
		}
		else
		{
			buf[0] = '+';
		}
		
		lcd_show_menu_layer(help_layer);
		help_layer_timer = 0; // display permanent
		
		vd_clear_rect(help_layer, 0, 12, 146, 43);

		vdisp_i2s(buf + 1, 2, 10, 1, new_volume);
		vd_prints_xy(help_layer, 30, 30, VDISP_FONT_6x8, 0, "Volume");
		vd_prints_xy(help_layer, 70, 30, VDISP_FONT_6x8, 0, buf);
		
		lcd_show_help_layer(help_layer);
		help_layer_timer = 3; // approx 2 seconds
	}
}
示例#2
0
文件: a_lib.c 项目: rballis/up4dar-os
static void set_help_text (void)
{
	const app_context_t * a = current_app;
	
	vd_clear_rect(help_layer, 0, 0, 40, 6); // name
	vd_prints_xy(help_layer, 0, 0, VDISP_FONT_4x6, 0, a->name);
	
	vd_clear_rect(help_layer, 0, 58, 25, 6); // button 1
	vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, a->button_text[0]);
	
	vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
	vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, a->button_text[1]);
	
	vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
	vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, a->button_text[2]);
	
	vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
	vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, a->button_text[3]);
	
	/*
	vd_clear_rect(help_layer, 91, 14, 32, 6); // button UP
	vd_prints_xy(help_layer, 91, 14, VDISP_FONT_4x6, 0, a->button_text[3]);
	
	vd_clear_rect(help_layer, 91, 38, 32, 6); // button DOWN
	vd_prints_xy(help_layer, 91, 38, VDISP_FONT_4x6, 0, a->button_text[4]);
	*/
}
示例#3
0
文件: ccs.c 项目: dl1bff/up4dar-os
void ccs_input_packet ( const uint8_t * data, int data_len, const uint8_t * ipv4_src_addr)
{
	if (memcmp(ipv4_src_addr, ccs_server_ipaddr, sizeof ipv4_addr) != 0)
	{
		// packet is not from the currently selected server
		return;
	}
	
	
	if (data_len == 14) // connect response packet
	{
		if (ccs_state == CCS_CONNECT_REQ_SENT)
		{
			if ((data[8] == repeater_callsign[7]) &&
			  (memcmp(data + 10, "ACK", 3) == 0))
			{
				ccs_rx_callsign[0] = 0;
				ccs_state = CCS_CONNECTED;
				ccs_timeout_timer = CCS_KEEPALIVE_TIMEOUT;
				vd_prints_xy(VDISP_DEBUG_LAYER, 104, 16, VDISP_FONT_6x8, 0, "ACK ");
			}
			else
			{
				ccs_state = CCS_DISCONNECTED;
				udp_socket_ports[UDP_SOCKET_CCS] = 0; // stop receiving frames
				vd_prints_xy(VDISP_DEBUG_LAYER, 104, 16, VDISP_FONT_6x8, 0, "NACK");
			} 
		}
		else if (ccs_state == CCS_DISCONNECT_REQ_SENT)
		{
			if (data[9] == ' ')
			{
				ccs_state = CCS_DISCONNECTED;
				udp_socket_ports[UDP_SOCKET_CCS] = 0; // stop receiving frames
				vd_prints_xy(VDISP_DEBUG_LAYER, 104, 16, VDISP_FONT_6x8, 0, "DISC");
			}
		}
	}
	else if (data_len == CCS_KEEPALIVE_RESP_FRAME_SIZE)  // keep alive packet 
	{
		if (ccs_state == CCS_CONNECTED)
		{
			ccs_timeout_timer = CCS_KEEPALIVE_TIMEOUT;
			ccs_keepalive_response();
		}
	}
}
示例#4
0
文件: a_lib.c 项目: rballis/up4dar-os
static void ref_print_status (void)
{
	
	vd_prints_xy(VDISP_REF_LAYER, 36, 12, VDISP_FONT_6x8, (ref_selected_item == 0),
		ref_modes[(int) ref_items[0]]);
	
	#define XPOS_NODEINFO_LAYER 10
	vd_prints_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER, 24, VDISP_FONT_6x8, (ref_selected_item == 1),
		ref_types[(int) ref_items[1]]);
	
	vd_printc_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER + 3*6, 24, VDISP_FONT_6x8, (ref_selected_item == 2),
		ref_items[2] + 0x30);
	vd_printc_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER + 4*6, 24, VDISP_FONT_6x8, (ref_selected_item == 3),
		ref_items[3] + 0x30);
	vd_printc_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER + 5*6, 24, VDISP_FONT_6x8, (ref_selected_item == 4),
		ref_items[4] + 0x30);
	
	vd_printc_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER + 6*6, 24, VDISP_FONT_6x8, (ref_selected_item == 5),
		0x20);
	vd_printc_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER + 7*6, 24, VDISP_FONT_6x8, (ref_selected_item == 5),
		ref_items[5] + 0x41);
	vd_printc_xy(VDISP_REF_LAYER, XPOS_NODEINFO_LAYER + 8*6, 24, VDISP_FONT_6x8, (ref_selected_item == 5),
		0x20);
		
	vd_clear_rect(VDISP_REF_LAYER, 0, 36, 120, 12);

	if (repeater_mode || hotspot_mode)
	{
		vd_prints_xy(VDISP_REF_LAYER, 0, 36, VDISP_FONT_6x8, 0, "Hometimer");
	
		vd_prints_xy(VDISP_REF_LAYER, 60, 36, VDISP_FONT_6x8, (ref_selected_item == 6),
			ref_timer[(int) ref_items[6]]);
	}
	
	#undef XPOS
}
示例#5
0
文件: main.c 项目: rballis/up4dar-os
static void vServiceTask( void *pvParameters )
{
	
	int last_backlight = -1;
	int last_contrast = -1;
	char last_repeater_mode = 0;
	char last_parrot_mode = 0;
	char dcs_boot_timer = 8;
	// bool update = true;
	bool last_rmu_enabled = false;

	for (;;)
	{	
		
		vTaskDelay(500); 
		
		// gpio_toggle_pin(AVR32_PIN_PB28);
		//gpio_toggle_pin(AVR32_PIN_PB18);
			
		// x_counter ++;
			
		
		// rtclock_disp_xy(84, 0, x_counter & 0x02, 1);
		rtclock_disp_xy(84, 0, 2, 1);
			
			
			
		vdisp_i2s( tmp_buf, 5, 10, 0, voltage);
		tmp_buf[3] = tmp_buf[2];
		tmp_buf[2] = '.';
		tmp_buf[4] = 'V';
		tmp_buf[5] = 0;
			
			
		vdisp_prints_xy( 55, 0, VDISP_FONT_4x6, 0, tmp_buf );
			
		// vdisp_i2s( tmp_buf, 5, 10, 0, serial_rx_error );
		// vd_prints_xy(VDISP_DEBUG_LAYER, 108, 28, VDISP_FONT_4x6, 0, tmp_buf );
		vdisp_i2s( tmp_buf, 5, 10, 0, serial_rx_ok );
		vd_prints_xy(VDISP_DEBUG_LAYER, 108, 34, VDISP_FONT_4x6, 0, tmp_buf );	
		// vdisp_i2s( tmp_buf, 5, 10, 0, serial_timeout_error );
		vdisp_i2s( tmp_buf, 5, 10, 0, dstar_pos_not_correct );
		vd_prints_xy(VDISP_DEBUG_LAYER, 108, 40, VDISP_FONT_4x6, 0, tmp_buf );
		vdisp_i2s( tmp_buf, 5, 10, 0, serial_putc_q_full );
		vd_prints_xy(VDISP_DEBUG_LAYER, 108, 46, VDISP_FONT_4x6, 0, tmp_buf );
		vdisp_i2s( tmp_buf, 5, 10, 0, initialHeapSize );
		vd_prints_xy(VDISP_DEBUG_LAYER, 108, 52, VDISP_FONT_4x6, 0, tmp_buf );
		vdisp_i2s( tmp_buf, 5, 10, 0, xPortGetFreeHeapSize() );
		vd_prints_xy(VDISP_DEBUG_LAYER, 108, 58, VDISP_FONT_4x6, 0, tmp_buf );
		
		
		int v = 0;
			
		switch (eth_autoneg_state)
		{
			case 0:
			if (SETTING_BOOL(B_ONLY_TEN_MBIT))
			{
				AVR32_MACB.man = 0x50920061; // write register 0x04, advertise only 10MBit/s for autoneg
			}
			eth_autoneg_state = 1;
			break;
			
			case 1:
			AVR32_MACB.man = 0x50821200; // write register 0x00, power on, autoneg, restart autoneg
			eth_autoneg_state = 2;
			break;
			
			case 2:
			AVR32_MACB.man = 0x60C20000; // read register 0x10
			eth_autoneg_state = 3;
			break;
			
			case 3:
			v = AVR32_MACB.MAN.data; // read data from previously read register 0x10
			AVR32_MACB.man = 0x60C20000; // read register 0x10
			break;
		}
		
		dvset();
		nodeinfo_print();
				
		if (last_rmu_enabled != rmu_enabled)
		{
			rmuset_print();
			last_rmu_enabled = rmu_enabled;
		}

			
		const char * net_status = "     ";
			
		dhcp_set_link_state( v & 1 );
			
		if (v & 1)  // Ethernet link is active
		{
			v = ((v >> 1) & 0x03) ^ 0x01;
				
			switch (v)
			{
				case 0:
					net_status = " 10HD";
					break;
				case 1:
					net_status = "100HD";
					break;
				case 2:
					net_status = " 10FD";
					break;
				case 3:
					net_status = "100FD";
					break;
			}
				
			AVR32_MACB.ncfgr = 0x00000800 | v;  // SPD, FD, CLK = MCK / 32 -> 1.875 MHz
				
			vdisp_prints_xy( 28, 0, VDISP_FONT_4x6, 
				(dhcp_is_ready() != 0) ? 0 : 1, net_status );
		}
		else
		{
示例#6
0
文件: rmuset.c 项目: st0ne/up4dar-os
void rmuset_print(void)
{
	char str[RMUSET_LINE_LENGTH];
	
	vd_clear_rect(VDISP_RMUSET_LAYER, 0, 12, 146, 43);
	
	vd_printc_xy(VDISP_RMUSET_LAYER, 120, 13, VDISP_FONT_8x12, 0, 0x1e); // arrow up
	vd_printc_xy(VDISP_RMUSET_LAYER, 120, 39, VDISP_FONT_8x12, 0, 0x1f); // arrow up
	
	vd_prints_xy(VDISP_RMUSET_LAYER, 0, 12, VDISP_FONT_5x8, 0, "TX-QRG:");
	vd_prints_xy(VDISP_RMUSET_LAYER, 0, 23, VDISP_FONT_5x8, 0, "RX-QRG:");


	vd_prints_xy(VDISP_RMUSET_LAYER, 93, 12, VDISP_FONT_5x8, 0, "MHz");
	vd_prints_xy(VDISP_RMUSET_LAYER, 93, 23, VDISP_FONT_5x8, 0, "MHz");
	
	if (!rmuset_enabled())
	{
		vd_prints_xy(VDISP_RMUSET_LAYER, 40, 12, VDISP_FONT_5x8, 0, "---.---.--");
		vd_prints_xy(VDISP_RMUSET_LAYER, 40, 23, VDISP_FONT_5x8, 0, "---.---.--");
		
		feld_selected_item = 6;
		enabled_invers = 1;
	}
	else
	{
		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, settings.s.qrg_tx, 3);
		vd_prints_xy(VDISP_RMUSET_LAYER, 39, 12, VDISP_FONT_5x8, tx_qrg_MHz_invers, str);
		vd_prints_xy(VDISP_RMUSET_LAYER, 54, 12, VDISP_FONT_5x8, 0, ".");
	
		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, settings.s.qrg_tx + 3, 1);
		vd_prints_xy(VDISP_RMUSET_LAYER, 59, 12, VDISP_FONT_5x8, tx_qrg_100kHz_invers, str);
	
		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, settings.s.qrg_tx + 4, 2);
		vd_prints_xy(VDISP_RMUSET_LAYER, 65, 12, VDISP_FONT_5x8, tx_qrg_6_25kHz_invers, str);

		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, ".", 1);
		memcpy(str + 1, settings.s.qrg_tx + 6, 2);
		vd_prints_xy(VDISP_RMUSET_LAYER, 75, 12, VDISP_FONT_5x8, tx_qrg_6_25kHz_invers, str);

		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, settings.s.qrg_rx, 3);
		vd_prints_xy(VDISP_RMUSET_LAYER, 39, 23, VDISP_FONT_5x8, rx_qrg_MHz_invers, str);
		vd_prints_xy(VDISP_RMUSET_LAYER, 54, 23, VDISP_FONT_5x8, 0, ".");
	
		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, settings.s.qrg_rx + 3, 1);
		vd_prints_xy(VDISP_RMUSET_LAYER, 59, 23, VDISP_FONT_5x8, rx_qrg_100kHz_invers, str);
	
		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, settings.s.qrg_rx + 4, 2);
		vd_prints_xy(VDISP_RMUSET_LAYER, 65, 23, VDISP_FONT_5x8, rx_qrg_6_25kHz_invers, str);

		memset(str, '\0', RMUSET_LINE_LENGTH);
		memcpy(str, ".", 1);
		memcpy(str + 1, settings.s.qrg_rx + 6, 2);
		vd_prints_xy(VDISP_RMUSET_LAYER, 75, 23, VDISP_FONT_5x8, rx_qrg_6_25kHz_invers, str);
	}
		
	vd_prints_xy(VDISP_RMUSET_LAYER, 40, 35, VDISP_FONT_5x8, enabled_invers, ref_enabled[rmuset_enabled()]);
}
示例#7
0
文件: dns2.c 项目: rballis/up4dar-os
int dns2_req_A (const char * name)
{
	
	int i;
	int handle = -1;
	int link_zero_slot = -1;
	int ttl_min = 65535;
	
	for (i=0; i < DNS_NUMBER_OF_ENTRIES; i++)
	{
		struct dns2_cache * cur = dc + i;
		
		if (cur->reqname_len == 0)
		{
			handle = i; // free slot
			break;
		}
		
		if (cur->link == 0) // slot currently not in use
		{
			if (cur->ttl < ttl_min)
			{
				ttl_min = cur->ttl;
				link_zero_slot = i; // unused slot with the lowest TTL
			}
		}
	}
	
	if (handle < 0)
	{
		if (link_zero_slot < 0) // could not find slot that is not in use
			return -1; // no free slots
	
		handle = link_zero_slot; // use entry with smallest ttl left	
	}
	
	if (dns2_parse_domain(handle, name) != 0)
	{
		return -1;  // something wrong with the requested name
	}
	
	struct dns2_cache * cur = dc + handle;
	
	for (i=0; i < DNS_NUMBER_OF_ENTRIES; i++)
	{		
		if (i == handle) // skip the newly created entry
			continue;
		
		struct dns2_cache * cached = dc + i;
		
		if (cur->reqname_len == cached->reqname_len)
		{
			if ((memcmp(cur->reqname, cached->reqname, cached->reqname_len) == 0)
				&& (cached->ttl > 0))
			{  // same name requested and some TTL left
				cached->link ++;
				cur->reqname_len = 0; // free the newly created handle
				return i; // return the cached handle 
			}
		}
	}
	
	if (strcmp(name, "tst002.reflector.up4dar.de") == 0)
	{
		memcpy (cur->result_data, tst002addr, sizeof tst002addr);
		cur->result_data_len = sizeof tst002addr;
		cur->state = DNS_STATE_RESULT_OK;
		cur->ttl = 5;
		cur->link = 1;
		return handle;
	}
		
	if (memcmp(ipv4_dns_pri, ipv4_zero_addr, sizeof ipv4_addr) == 0)
	{  // no primary DNS server
		return -1;
	}
		
	cur->retry = DNS_REQ_RETRY;
	cur->timeout = 0;
	cur->primary_server = 1; // begin with primary server
	cur->link = 1; // one client links to this
	cur->state = DNS_STATE_REQ_A;
	cur->udp_local_port = 0; // select new port
	
	vd_prints_xy(VDISP_DEBUG_LAYER, 0, 48, VDISP_FONT_4x6, 0, "AREQ");
	vd_prints_xy(VDISP_DEBUG_LAYER, 20, 48, VDISP_FONT_4x6, 0, name);
	vd_clear_rect(VDISP_DEBUG_LAYER, 0, 54, 80, 6);
	return handle; // OK
}
示例#8
0
文件: gps.c 项目: st0ne/up4dar-os
static void recv_gpgsv(int num_sats)
{
	int total = get_nmea_num(1);
	int msgnum = get_nmea_num(2);
	
	if (msgnum == 1) // first msg
	{
		gps_init_satlist();  // clear list
	}
	
	
	
	int j;
	int i;
	
	for (i=0; i < num_sats; i++)
	{
		int s_ptr = i + ((msgnum - 1) << 2);
		
		if (s_ptr < MAX_SATELLITES)
		{
			if ( (*(nmea_params[ 4 + i * 4 ])) == 0) // empty parameter
			{
				sats[s_ptr].sat_id = NO_SAT;
			}
			else
			{
				sats[s_ptr].sat_id = get_nmea_num( 4 + i * 4 );
				sats[s_ptr].elevation = get_nmea_num( 5 + i * 4 );
				sats[s_ptr].azimuth = get_nmea_num( 6 + i * 4 );
				sats[s_ptr].snr = get_nmea_num( 7 + i * 4 );
			}
			
		}
	}

	if (msgnum == total) // last record, print it
	{
		vd_clear_rect (VDISP_GPS_LAYER, 0, 0, 128, 64);
		
		
		if (gps_fix >= 2)
		{
			buf[0] = 0x30 + gps_fix;
			buf[1] = 0;
			
			vd_prints_xy(VDISP_GPS_LAYER, 62, 46, VDISP_FONT_4x6, 0, buf);
			vd_prints_xy(VDISP_GPS_LAYER, 66, 46, VDISP_FONT_4x6, 0, "D FIX");
		}
		else
		{
			vd_prints_xy(VDISP_GPS_LAYER, 62, 46, VDISP_FONT_4x6, 0, "NO FIX");
		}
		
		/*
		if (gpgga_fix_info > 0)
		{
			buf[0] = 0x30 + gpgga_fix_info;
			buf[1] = 0;
			
			vd_prints_xy(VDISP_GPS_LAYER, 0, 56, VDISP_FONT_6x8, 0, buf);
		}
		else
		{
			vd_prints_xy(VDISP_GPS_LAYER, 0, 56, VDISP_FONT_6x8, 0, "-");
		}
		
		if (gprmc_fix_mode > 0)
		{
			buf[0] = gprmc_fix_mode;
			buf[1] = 0;
			
			vd_prints_xy(VDISP_GPS_LAYER, 6, 0, VDISP_FONT_6x8, 0, buf);
		}
		else
		{
			vd_prints_xy(VDISP_GPS_LAYER, 6, 0, VDISP_FONT_6x8, 0, "-");
		}
		
		if (gprmc_status > 0)
		{
			buf[0] = gprmc_status;
			buf[1] = 0;
			
			vd_prints_xy(VDISP_GPS_LAYER, 12, 0, VDISP_FONT_6x8, 0, buf);
		}
		else
		{
			vd_prints_xy(VDISP_GPS_LAYER, 12, 0, VDISP_FONT_6x8, 0, "-");
		}
		*/
		
		/*
		for (i=0; i < 360; i+= 45)
		{
			vd_set_pixel(VDISP_GPS_LAYER, 32 + (fixpoint_sin(i) / 700),
				32 + (fixpoint_cos(i) / 700), 0, 1, 1);
		}
		*/
		
		for (i=0; i < 360; i+= 10)
		{
			vd_set_pixel(VDISP_GPS_LAYER, 32 + (fixpoint_sin(i) / 357),
				32 + (fixpoint_cos(i) / 357), 0, 1, 1);
		}			
				
		vd_prints_xy(VDISP_GPS_LAYER, 0, 28, VDISP_FONT_6x8, 0, "W");
		vd_prints_xy(VDISP_GPS_LAYER, 58, 28, VDISP_FONT_6x8, 0, "E");
		vd_prints_xy(VDISP_GPS_LAYER, 29, 0, VDISP_FONT_6x8, 0, "N");
		vd_prints_xy(VDISP_GPS_LAYER, 29, 56, VDISP_FONT_6x8, 0, "S");
		
		
		for (i=0; i < MAX_SATELLITES; i++)
		{
			if (sats[i].sat_id != NO_SAT)
			{
				int x = 120 - (i % 6) * 10;
				int y = (i / 6) * 21;
				
				
				
				int used_in_fix = 0;
				
				for (j=0; j < GPGSA_NUM_DATA; j++)
				{
					if (sats[i].sat_id == gpgsa_data[j])
					{
						used_in_fix = 1;
					}
				}
				
				if (sats[i].elevation > 0)
				{
					int xx = 28 + fixpoint_cos(sats[i].elevation) * fixpoint_sin(sats[i].azimuth) / 3570000;
					int yy = 29 - fixpoint_cos(sats[i].elevation) * fixpoint_cos(sats[i].azimuth) / 3570000;
					
					vdisp_i2s(buf, 2, 10, 1, sats[i].sat_id);
					vd_prints_xy(VDISP_GPS_LAYER, xx, yy+1, VDISP_FONT_4x6, used_in_fix, buf);
					
					for (j=0; j < 8; j++)
					{
						vd_set_pixel(VDISP_GPS_LAYER, xx + j, yy, 0, used_in_fix, 1);
					}
					
					for (j=0; j < 7; j++)
					{
						vd_set_pixel(VDISP_GPS_LAYER, xx + 8, yy + j, 0, used_in_fix, 1);
					}
				}
				
				vdisp_i2s(buf, 2, 10, 1, sats[i].sat_id);
				vd_prints_xy(VDISP_GPS_LAYER, x, y + 14, VDISP_FONT_4x6, 0, buf);
				
				int v = fixpoint_sin(sats[i].snr) / 833;
				
				vd_set_pixel(VDISP_GPS_LAYER, x+1, y + 12, 0, 0x7F, 7);
				
				for (j=1; j < v; j++)
				{
					vd_set_pixel(VDISP_GPS_LAYER, x+1, y + 12 - j, 0,
						used_in_fix ? 0x7F : 0x41 , 7);
				}
				
				vd_set_pixel(VDISP_GPS_LAYER, x+1, y + 12 - v, 0, 0x7F, 7);
				
				/*
				vdisp_i2s(buf, 3, 10, 1, sats[i].sat_id);
				vd_prints_xy(VDISP_GPS_LAYER, x +  0, y, VDISP_FONT_4x6, used_in_fix, buf);
			
				vdisp_i2s(buf, 2, 10, 1, sats[i].elevation);
				vd_prints_xy(VDISP_GPS_LAYER, x + 16, y, VDISP_FONT_4x6, 0, buf);	
				
				vdisp_i2s(buf, 3, 10, 1, sats[i].azimuth);
				vd_prints_xy(VDISP_GPS_LAYER, x + 28, y, VDISP_FONT_4x6, 0, buf);
				
				vdisp_i2s(buf, 2, 10, 1, sats[i].snr);
				vd_prints_xy(VDISP_GPS_LAYER, x + 44, y, VDISP_FONT_4x6, 0, buf);	
				
				*/
			}
		}
		
		
	}
	
	
	for (i=0; i < 2; i++)
	{
		vd_prints_xy(VDISP_GPS_LAYER, 56, 52 + (i*6), VDISP_FONT_4x6, 0, fix_data[i]);
	}	
	
	
	/*
	vdisp_i2s(buf, 2, 10, 1, get_nmea_num(1));
	vd_prints_xy(VDISP_GPS_LAYER, 0, 58, VDISP_FONT_4x6, 0, buf);
	vdisp_i2s(buf, 2, 10, 1, get_nmea_num(2));
	vd_prints_xy(VDISP_GPS_LAYER, 12, 58, VDISP_FONT_4x6, 0, buf);
	vdisp_i2s(buf, 2, 10, 1, get_nmea_num(3));
	vd_prints_xy(VDISP_GPS_LAYER, 24, 58, VDISP_FONT_4x6, 0, buf);
	*/
}
示例#9
0
文件: ccs.c 项目: dl1bff/up4dar-os
void ccs_service (void)
{
	if (ccs_timeout_timer > 0)
	{
		ccs_timeout_timer --;
	}
	
	
	switch (ccs_state)
	{
		case CCS_CONNECTED:
		if (ccs_timeout_timer == 0)
		{
			ccs_timeout_timer = 2; // 1 second
			ccs_state = CCS_WAIT;
			udp_socket_ports[UDP_SOCKET_CCS] = 0; // stop receiving frames
			vd_prints_xy(VDISP_DEBUG_LAYER, 104, 16, VDISP_FONT_6x8, 0, "NOWD");
		}
		else
		{
			if (ccs_rx_callsign[0] != 0)
			{
				ccs_send_info_frame();
				ccs_rx_callsign[0] = 0;
			}
		}
		break;
		
		
		
		case CCS_CONNECT_REQ_SENT:
		if (ccs_timeout_timer == 0)
		{
			if (ccs_retry_counter > 0)
			{
				ccs_retry_counter --;
			}
			
			if (ccs_retry_counter == 0)
			{
				ccs_timeout_timer = CCS_FAILURE_TIMEOUT;
				ccs_state = CCS_WAIT;
				// ccs_next_server();
				udp_socket_ports[UDP_SOCKET_CCS] = 0; // stop receiving frames
				vd_prints_xy(VDISP_DEBUG_LAYER, 104, 16, VDISP_FONT_6x8, 0, "RQTO");
			}
			else
			{
				ccs_send_connect();
				ccs_timeout_timer = CCS_CONNECT_REQ_TIMEOUT;
			}
		}
		break;
		
		case CCS_DISCONNECT_REQ:
			ccs_send_disconnect();
			ccs_timeout_timer = CCS_DISCONNECT_REQ_TIMEOUT;
			ccs_state = CCS_DISCONNECT_REQ_SENT;
			ccs_retry_counter = CCS_DISCONNECT_RETRIES;
		
		break;
		
		
		case CCS_DISCONNECT_REQ_SENT:
		if (ccs_timeout_timer == 0)
		{
			if (ccs_retry_counter > 0)
			{
				ccs_retry_counter --;
			}
			
			if (ccs_retry_counter == 0)
			{
				ccs_state = CCS_DISCONNECTED;
				udp_socket_ports[UDP_SOCKET_CCS] = 0; // stop receiving frames
			}
			else
			{
				ccs_send_disconnect();
				ccs_timeout_timer = CCS_DISCONNECT_REQ_TIMEOUT;
			}
		}
		break;
		
		case CCS_DNS_REQ:
		
		dns_handle = dns2_req_A(ccs_current_servername());
		
		if (dns_handle >= 0) // resolver not busy
		{
			ccs_state = CCS_DNS_REQ_SENT;
		}
		else if (ccs_timeout_timer == 0)
		{
			if (ccs_retry_counter > 0)
			{
				ccs_retry_counter --;
			}
			
			if (ccs_retry_counter == 0)
			{
				ccs_timeout_timer = CCS_FAILURE_TIMEOUT;
				ccs_state = CCS_WAIT;
				// ccs_next_server();
			}
			else
			{
				ccs_timeout_timer = CCS_DNS_TIMEOUT;
			}
		}
		break;
		
		case CCS_DNS_REQ_SENT:
		if (dns2_result_available(dns_handle)) // resolver is ready
		{
			uint8_t * addrptr;
			if (dns2_get_A_addr(dns_handle, &addrptr) <= 0) // DNS didn't work
			{
				ccs_timeout_timer = CCS_FAILURE_TIMEOUT;
				ccs_state = CCS_WAIT;
				// ccs_next_server();
			}
			else
			{
				memcpy (ccs_server_ipaddr, addrptr, 4); // use first address of DNS result
				
				udp_socket_ports[UDP_SOCKET_CCS] = udp_get_new_srcport();
				
				ccs_send_connect();
				
				ccs_state = CCS_CONNECT_REQ_SENT;
				ccs_retry_counter = CCS_CONNECT_RETRIES;
				ccs_timeout_timer =  CCS_CONNECT_REQ_TIMEOUT;
			}
			
			dns2_free(dns_handle);
		}
		break;
		
		case CCS_WAIT:
		if (ccs_timeout_timer == 0)
		{
			ccs_retry_counter = CCS_DNS_INITIAL_RETRIES;
			ccs_timeout_timer = CCS_DNS_TIMEOUT;
			ccs_state = CCS_DNS_REQ;
		}
		break;
	}
}
示例#10
0
void nodeinfo_print(void)
{
	char str[NODEINFO_LINE_LENGTH];
	
	vd_clear_rect(VDISP_NODEINFO_LAYER, 0, 12, 146, 43);
	
	vd_printc_xy(VDISP_NODEINFO_LAYER, 120, 13, VDISP_FONT_8x12, 0, 0x1e); // arrow up
	vd_printc_xy(VDISP_NODEINFO_LAYER, 120, 39, VDISP_FONT_8x12, 0, 0x1f); // arrow up
	
	vd_prints_xy(VDISP_NODEINFO_LAYER, 0, 12, VDISP_FONT_5x8, 0, "LAT:");
	vd_prints_xy(VDISP_NODEINFO_LAYER, 0, 22, VDISP_FONT_5x8, 0, "LON:");
	vd_prints_xy(VDISP_NODEINFO_LAYER, 0, 32, VDISP_FONT_5x8, 0, "QRG:");
	vd_prints_xy(VDISP_NODEINFO_LAYER, 0, 42, VDISP_FONT_5x8, 0, "DUP:");
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lat, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER, 12, VDISP_FONT_5x8, (nodeinfo_pos == 0), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lat + 1, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 1 * 5, 12, VDISP_FONT_5x8, (nodeinfo_pos == 1), str);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 2 * 5, 12, VDISP_FONT_5x8, 0, ".");
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lat + 2, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 3 * 5, 12, VDISP_FONT_5x8, (nodeinfo_pos == 2), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lat + 3, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 4 * 5, 12, VDISP_FONT_5x8, (nodeinfo_pos == 3), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lat + 4, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 5 * 5, 12, VDISP_FONT_5x8, (nodeinfo_pos == 4), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lat + 5, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 6 * 5, 12, VDISP_FONT_5x8, (nodeinfo_pos == 5), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lon, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER, 22, VDISP_FONT_5x8, (nodeinfo_pos == 6), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lon + 1, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 1 * 5, 22, VDISP_FONT_5x8, (nodeinfo_pos == 7), str);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 2 * 5, 22, VDISP_FONT_5x8, 0, ".");
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lon + 2, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 3 * 5, 22, VDISP_FONT_5x8, (nodeinfo_pos == 8), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lon + 3, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 4 * 5, 22, VDISP_FONT_5x8, (nodeinfo_pos == 9), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lon + 4, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 5 * 5, 22, VDISP_FONT_5x8, (nodeinfo_pos == 10), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_pos_lon + 5, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 6 * 5, 22, VDISP_FONT_5x8, (nodeinfo_pos == 11), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_qrg, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER, 32, VDISP_FONT_5x8, (nodeinfo_pos == 12), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_qrg + 1, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 1 * 5, 32, VDISP_FONT_5x8, (nodeinfo_pos == 13), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_qrg + 2, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 2 * 5, 32, VDISP_FONT_5x8, (nodeinfo_pos == 14), str);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 3 * 5, 32, VDISP_FONT_5x8, 0, ".");

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_qrg + 3, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 4 * 5, 32, VDISP_FONT_5x8, (nodeinfo_pos == 15), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_qrg + 4, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 5 * 5, 32, VDISP_FONT_5x8, (nodeinfo_pos == 16), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_qrg + 5, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 6 * 5, 32, VDISP_FONT_5x8, (nodeinfo_pos == 17), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_dup, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER, 42, VDISP_FONT_5x8, (nodeinfo_pos == 18), str);
	
	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_dup + 1, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 1 * 5, 42, VDISP_FONT_5x8, (nodeinfo_pos == 19), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_dup + 2, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 2 * 5, 42, VDISP_FONT_5x8, (nodeinfo_pos == 20), str);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 3 * 5, 42, VDISP_FONT_5x8, 0, ".");

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_dup + 3, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 4 * 5, 42, VDISP_FONT_5x8, (nodeinfo_pos == 21), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_dup + 4, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 5 * 5, 42, VDISP_FONT_5x8, (nodeinfo_pos == 22), str);

	memset(str, '\0', NODEINFO_LINE_LENGTH);
	memcpy(str, settings.s.node_dup + 5, 1);
	vd_prints_xy(VDISP_NODEINFO_LAYER, XPOS_NODEINFO_LAYER + 6 * 5, 42, VDISP_FONT_5x8, (nodeinfo_pos == 23), str);
}
示例#11
0
文件: a_lib.c 项目: rballis/up4dar-os
static int main_app_key_event_handler (void * app_context, int key_num, int event_type)
{
	// app_context_t * a = (app_context_t *) app_context;
	
	if ((key_num == A_KEY_BUTTON_1) && (event_type == A_KEY_PRESSED))
	{
		software_ptt = 1;
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_1) && (event_type == A_KEY_RELEASED))
	{
		software_ptt = 0;
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_2) && (event_type == A_KEY_RELEASED))
	{
		if ((!key_douple_function) && (key_lock == 0))
		{
			if (ambe_get_automute() != 0) // automute is currently on
			{
				ambe_set_automute(0);
			}
			else
			{
				ambe_set_automute(1);
			}
		}
		else
		{
			key_douple_function = false;
		}
		
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_2) && (event_type == A_KEY_HOLD_2S))
	{
		key_douple_function = true;
		if (key_lock != 0)
		{
			key_lock = 0;
		}
		else
		{
			key_lock = 1;
		}
	}
	else if ((key_num == A_KEY_BUTTON_3) && (event_type == A_KEY_PRESSED))
	{
		if (r2cs_count() >= 0)
		{
			if (!r2cs_flag)
			{
				r2cs_flag = true;
				r2cs_idx = 0;

				lcd_show_menu_layer(help_layer);
				help_layer_timer = 0; // display permanent
			
				a_set_button_text_pos(main_screen, "SET", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
				
				r2cs_print(help_layer, r2cs_idx);
			}
			else
			{
				lcd_show_menu_layer(help_layer);
				help_layer_timer = 3; // approx 2 seconds

				a_set_button_text_pos(main_screen, "R>CS", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);

				r2cs_flag = false;
				r2cs(help_layer, r2cs_idx);
			}
		}
		
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_3) && (event_type == A_KEY_HOLD_2S))
	{
		r2cs_flag = false;
		lcd_show_menu_layer(help_layer);
		help_layer_timer = 3; // approx 2 seconds
		r2cs(help_layer, -1);
		
		a_set_button_text_pos(main_screen, "R>CS", 2);
		vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
		vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
		
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_DOWN) && (event_type == A_KEY_PRESSED) && (r2cs_flag) && (r2cs_idx < r2cs_count()))
	{
		r2cs_idx++;
		r2cs_print(help_layer, r2cs_idx);
		
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_UP) && (event_type == A_KEY_PRESSED) && (r2cs_flag) && (r2cs_idx > 0))
	{
		r2cs_idx--;
		r2cs_print(help_layer, r2cs_idx);
		
		return 1;
	}
	
	return 0;
}
示例#12
0
文件: a_lib.c 项目: rballis/up4dar-os
static int dvset_app_key_event_handler (void * app_context, int key_num, int event_type)
{
	// app_context_t * a = (app_context_t *) app_context;
	
	if ((key_num == A_KEY_BUTTON_1) && (event_type == A_KEY_PRESSED))
	{
		refresh_main_menu = true;

		if (dvset_isedit())
		{
			a_set_button_text_pos(main_screen, "WRITE", 0);
			vd_clear_rect(help_layer, 0, 58, 24, 6); // button 1
			vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, main_screen->button_text[0]);
			
			a_set_button_text_pos(main_screen, "CLEAR", 1);
			vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
			vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, main_screen->button_text[1]);
			
			a_set_button_text_pos(main_screen, "EDIT", 2);
			vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
			vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
			
			a_set_button_text_pos(main_screen, "CANCEL", 3);
			vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
			vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, main_screen->button_text[3]);
			
			dvset_store();
		}
		else
		{
			if (!dvset_isselected())
			{
				a_set_button_text_pos(main_screen, "WRITE", 0);
				vd_clear_rect(help_layer, 0, 58, 24, 6); // button 1
				vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, main_screen->button_text[0]);
			
				a_set_button_text_pos(main_screen, "CLEAR", 1);
				vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
				vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, main_screen->button_text[1]);
			
				a_set_button_text_pos(main_screen, "EDIT", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
			
				a_set_button_text_pos(main_screen, "CANCEL", 3);
				vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
				vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, main_screen->button_text[3]);
			
				dvset_select(true);
			}
			else
			{
				a_set_button_text_pos(main_screen, "SELECT", 0);
				vd_clear_rect(help_layer, 0, 58, 24, 6); // button 1
				vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, main_screen->button_text[0]);
			
				a_set_button_text_pos(main_screen, "", 1);
				vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
				vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, main_screen->button_text[1]);
			
				a_set_button_text_pos(main_screen, "", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
			
				a_set_button_text_pos(main_screen, "MENU", 3);
				vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
				vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, main_screen->button_text[3]);
			
				dvset_select(false);
			}
		}
			
		dvset_print();
	}
	else if ((key_num == A_KEY_BUTTON_2) && (event_type == A_KEY_PRESSED))
	{
		if (dvset_isedit())
		{
			dvset_backspace();
		}
		else
		{
			dvset_clear();
		}

		dvset_print();
	}
	else if ((key_num == A_KEY_BUTTON_3) && (event_type == A_KEY_PRESSED))
	{
		if (dvset_isedit())
		{
			dvset_cursor(0);
		}
		else
		{
			refresh_main_menu = true;

			a_set_button_text_pos(main_screen, "STORE", 0);
			vd_clear_rect(help_layer, 0, 58, 24, 6); // button 1
			vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, main_screen->button_text[0]);
			
			a_set_button_text_pos(main_screen, "BS", 1);
			vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
			vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, main_screen->button_text[1]);
			
			a_set_button_text_pos(main_screen, "   <", 2);
			vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
			vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
			
			a_set_button_text_pos(main_screen, "   >", 3);
			vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
			vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, main_screen->button_text[3]);
			
			dvset_goedit();
		}
		
		dvset_print();
	}
	else if ((key_num == A_KEY_BUTTON_DOWN) && (event_type == A_KEY_PRESSED || event_type == A_KEY_REPEAT))
	{
		dvset_field(1);
			
		dvset_print();
		
		return 1;
	}
	else if ((key_num == A_KEY_BUTTON_UP) && (event_type == A_KEY_PRESSED || event_type == A_KEY_REPEAT))
	{
		dvset_field(0);
			
		dvset_print();
		
		return 1;
	}
	
	return 1;
}
示例#13
0
文件: a_lib.c 项目: rballis/up4dar-os
void a_dispatch_key_event( int layer_num, int key_num, int key_event )
{
	if ((key_lock) && (key_num != A_KEY_BUTTON_2)) return;
	
	if (key_num == A_KEY_BUTTON_APP_MANAGER)
	{
		if (key_event == A_KEY_PRESSED)
		{
			if (dvset_isedit())
			{
				dvset_cursor(1);
				dvset_print();
				
				return;
			}
			else if (dvset_isselected())
			{
				a_set_button_text_pos(main_screen, "SELECT", 0);
				vd_clear_rect(help_layer, 0, 58, 24, 6); // button 1
				vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, main_screen->button_text[0]);

				a_set_button_text_pos(main_screen, "", 1);
				vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
				vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, main_screen->button_text[1]);
				
				a_set_button_text_pos(main_screen, "", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
				
				a_set_button_text_pos(main_screen, "MENU", 3);
				vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
				vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, main_screen->button_text[3]);

				settings_init();
				dvset_cancel();
				dvset_print();
				
				refresh_main_menu = true;
			
				return;
			}
			else if (r2cs_flag)
			{
				r2cs_flag = false;
				lcd_show_menu_layer(help_layer);
				help_layer_timer = 3; // approx 2 seconds
			
				a_set_button_text_pos(main_screen, "R>CS", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
			
				return;
			}
			
			if (refresh_main_menu)
			{
				a_set_button_text_pos(main_screen, "PTT", 0);
				vd_clear_rect(help_layer, 0, 58, 24, 6); // button 1
				vd_prints_xy(help_layer, 0, 58, VDISP_FONT_4x6, 0, main_screen->button_text[0]);

				a_set_button_text_pos(main_screen, "MUTE", 1);
				vd_clear_rect(help_layer, 34, 58, 24, 6); // button 2
				vd_prints_xy(help_layer, 34, 58, VDISP_FONT_4x6, 0, main_screen->button_text[1]);
				
				a_set_button_text_pos(main_screen, "R>CS", 2);
				vd_clear_rect(help_layer, 66, 58, 24, 6); // button 3
				vd_prints_xy(help_layer, 66, 58, VDISP_FONT_4x6, 0, main_screen->button_text[2]);
				
				a_set_button_text_pos(main_screen, "MENU", 3);
				vd_clear_rect(help_layer, 98, 58, 24, 6); // button 4
				vd_prints_xy(help_layer, 98, 58, VDISP_FONT_4x6, 0, main_screen->button_text[3]);

				refresh_main_menu = false;
			}
		
			snmp_reset_cmnty = 0;
			
			software_ptt = 0; // prevent TXing forever...
			
			app_manager_select_next();
			lcd_show_help_layer(help_layer);
			
			if ((current_app->screen_num == VDISP_REF_LAYER) ||
				(current_app->screen_num == VDISP_DVSET_LAYER) ||
				(current_app->screen_num == VDISP_MAIN_LAYER && r2csURCALL()))
			{
				help_layer_timer = 0; // show help forever..
			}
			else if (current_app->screen_num == VDISP_RMUSET_LAYER)
			{
				help_layer_timer = 0; // show help forever..

				rmuset_print();				
			}
			else
			{
				help_layer_timer = 5; // approx 2 seconds
			}			
		}
		
		if (key_event == A_KEY_HOLD_5S)
		{
			if (SETTING_CHAR(C_DISABLE_UDP_BEACON) != 0)  // toggle UDP beacon
			{
				SETTING_CHAR(C_DISABLE_UDP_BEACON) = 0; // beacon is now on
				dhcp_init(0); // switch on DHCP
				wm8510_beep(50, 1200, 100);
				
				snmp_reset_cmnty = 1;
			}
			else
			{
				SETTING_CHAR(C_DISABLE_UDP_BEACON) = 1; // // beacon is now off
				wm8510_beep(800, 300, 100);
			}
		}
		
		if (key_event == A_KEY_HOLD_10S)
		{
			if ((snmp_reset_cmnty == 2) && (SETTING_CHAR(C_DISABLE_UDP_BEACON) == 0))
			{
				settings.s.snmp_cmnty[0] = 0; // erase first byte, new string will then
				   // be generated automatically
				wm8510_beep(500, 1200, 100);
				snmp_reset_cmnty = 0;
			}
		}			
		
	}
	else
	{
		if (snmp_reset_cmnty == 1)
		{
			if ((key_num == A_KEY_BUTTON_UP) && (key_event == A_KEY_HOLD_2S))
			{
				snmp_reset_cmnty = 2;
			}
		}
		
		int res = 0;
		
		if (layer_num == VDISP_CURRENT_LAYER)
		{
			if (current_app->key_event_handler != NULL)
			{
				res = current_app->key_event_handler(current_app, key_num, key_event);
			}
		}
		else
		{
			app_context_t * tmp_app = app_list_head;
			
			while (tmp_app != NULL)
			{
				if ((tmp_app->screen_num == layer_num) && 
					(tmp_app->key_event_handler != NULL))
				{
					res = tmp_app->key_event_handler(tmp_app, key_num, key_event);
					break;
				}
				
				tmp_app = tmp_app->next;
			}
		}
		
		if (res == 0) // handler didn't use this event
		{
			if (((key_event == A_KEY_PRESSED) || (key_event == A_KEY_REPEAT)) && (!r2cs_flag))
			{
				switch (key_num)
				{
					case A_KEY_BUTTON_UP:
						set_speaker_volume(1);
						break;
						
					case A_KEY_BUTTON_DOWN:
						set_speaker_volume(0);
						break;
				}
			}				
		}
	}			
}
示例#14
0
文件: a_lib.c 项目: rballis/up4dar-os
void tx_info_on(void)
{
	if ((!tx_info)  && (!r2cs_flag) && (current_app->screen_num == VDISP_MAIN_LAYER))
	{
		char str[22];

		lcd_show_menu_layer(help_layer);
		help_layer_timer = 0; // display permanent
	
		vd_clear_rect(help_layer, 0, 12, 146, 43);	

		for (int i = 8; i < 66; i++)
		{
			vd_set_pixel(help_layer, i, 19, 0, 1, 1);
			vd_set_pixel(help_layer, i, 30, 0, 1, 1);
			vd_set_pixel(help_layer, i + 1, 31, 0, 1, 1);
		}
		for (int i = 19; i < 30; i++)
		{
			vd_set_pixel(help_layer, 8, i, 0, 1, 1);
			vd_set_pixel(help_layer, 65, i, 0, 1, 1);
			vd_set_pixel(help_layer, 66, i + 1, 0, 1, 1);
		}
	
		for (int i = 8; i < 112; i++)
		{
			vd_set_pixel(help_layer, i, 37, 0, 1, 1);
			vd_set_pixel(help_layer, i, 48, 0, 1, 1);
			vd_set_pixel(help_layer, i + 1, 49, 0, 1, 1);
		}
		for (int i = 37; i < 49; i++)
		{
			vd_set_pixel(help_layer, 8, i, 0, 1, 1);
			vd_set_pixel(help_layer, 112, i, 0, 1, 1);
			vd_set_pixel(help_layer, 113, i + 1, 0, 1, 1);
		}

		memset(str, '\0', 22);
		memcpy(str, getURCALL(), CALLSIGN_LENGTH);
	
		vd_prints_xy(help_layer, 10, 21, VDISP_FONT_5x8, 0, "ur");
		vd_prints_xy(help_layer, 20, 21, VDISP_FONT_5x8, 0, str);
	
		vd_prints_xy(help_layer, 70, 18, VDISP_FONT_4x6, 0, "R1");
		vd_prints_xy(help_layer, 70, 26, VDISP_FONT_4x6, 0, "R2");
		
		if (SETTING_CHAR(C_DV_DIRECT) != 1)
		{
			memset(str, '\0', 22);
		
			memcpy(str, settings.s.rpt1 + ((SETTING_CHAR(C_DV_USE_RPTR_SETTING) - 1)*CALLSIGN_LENGTH), CALLSIGN_LENGTH);
		
			vd_prints_xy(help_layer, 80, 18, VDISP_FONT_4x6, 0, str);
		
			memset(str, '\0', 22);
		
			memcpy(str, settings.s.rpt2 + ((SETTING_CHAR(C_DV_USE_RPTR_SETTING) - 1)*CALLSIGN_LENGTH), CALLSIGN_LENGTH);
		
			vd_prints_xy(help_layer, 80, 26, VDISP_FONT_4x6, 0, str);
		}
		else
		{
			vd_prints_xy(help_layer, 80, 18, VDISP_FONT_4x6, 0, "DIRECT  ");
			vd_prints_xy(help_layer, 80, 26, VDISP_FONT_4x6, 0, "DIRECT  ");
		}
	
		memset(str, '\0', 22);
		memcpy(str, settings.s.txmsg, TXMSG_LENGTH);
	
		vd_prints_xy(help_layer, 10, 40, VDISP_FONT_5x8, 0, str);

		tx_info = true;
	}
}
示例#15
0
文件: a_lib.c 项目: rballis/up4dar-os
void a_app_manager_init(void)
{
	
	app_context_t * a;
	
	a = a_new_app( "DSTAR", VDISP_MAIN_LAYER);
	a_set_button_text(a, "PTT", "MUTE", "R>CS", "MENU");
	a_set_key_event_handler(a, main_app_key_event_handler);
	main_screen = a;
	
	a = a_new_app( "RMU SET", VDISP_RMUSET_LAYER);
	a_set_button_text(a, "", "", "SELECT", "MENU");
	a_set_key_event_handler(a, rmuset_app_key_event_handler);
	
	a = a_new_app( "DV SET", VDISP_DVSET_LAYER);
	a_set_button_text(a, "SELECT", "", "", "MENU");
	a_set_key_event_handler(a, dvset_app_key_event_handler);
	
	a = a_new_app( "GPS", VDISP_GPS_LAYER);
	a_set_button_text(a, "", "", "", "MENU");
	
	a = a_new_app( "MODE SET", VDISP_REF_LAYER);
	a_set_button_text(a, "CONNECT", "DISC", "SELECT", "MENU");
	a_set_key_event_handler(a, ref_app_key_event_handler);
	
	a = a_new_app( "AUDIO", VDISP_AUDIO_LAYER);
	a_set_button_text(a, "", "", "", "MENU");
	// a_set_key_event_handler(a, debug_app_key_event_handler);
	
	a = a_new_app( "DEBUG", VDISP_DEBUG_LAYER);
	a_set_button_text(a, "", "REBOOT", "", "MENU");
	a_set_key_event_handler(a, debug_app_key_event_handler);
	
	a = a_new_app( "NODE INFO", VDISP_NODEINFO_LAYER);
	a_set_button_text(a, "GPS", "", "", "MENU");
	// a_set_key_event_handler(a, debug_app_key_event_handler);
	
	help_layer = vd_new_screen();
	
	if ((SETTING_SHORT(S_REF_SERVER_NUM) > 0) &&
	     (SETTING_SHORT(S_REF_SERVER_NUM) < 1000))
	{
		int n = SETTING_SHORT(S_REF_SERVER_NUM);
		
		ref_items[4] = n % 10;
		n /= 10;
		ref_items[3] = n % 10;
		n /= 10;
		ref_items[2] = n % 10;
	}
	
	if ((SETTING_CHAR(C_REF_MODULE_CHAR) >= 'A') &&
		(SETTING_CHAR(C_REF_MODULE_CHAR) <= 'Z'))
	{
		ref_items[5] = SETTING_CHAR(C_REF_MODULE_CHAR) - 0x41;
	}
	
	if ((SETTING_CHAR(C_REF_TIMER) >= 0) &&
		(SETTING_CHAR(C_REF_TIMER) <= 7))
	{
		ref_items[6] = SETTING_CHAR(C_REF_TIMER);
	}
	
	if ((SETTING_CHAR(C_DCS_MODE) >= 0) &&
		(SETTING_CHAR(C_DCS_MODE) <= 5))
	{
		ref_items[0] = SETTING_CHAR(C_DCS_MODE);
	}		
	
	if ((SETTING_CHAR(C_REF_TYPE) >= 0) &&
		(SETTING_CHAR(C_REF_TYPE) <= 2))
	{
		ref_items[1] = SETTING_CHAR(C_REF_TYPE);
	}
	
	set_mode_vars();
	
	int n = ref_items[2] * 100 +
	ref_items[3] * 10 +
	ref_items[4];
	
	dcs_select_reflector( n, ref_items[5] + 0x41,  ref_items[1]);
	
	if ((dcs_mode != 0)  && 
		(SETTING_CHAR(C_DCS_CONNECT_AFTER_BOOT) == 1)) 
	{
		ref_selected_item = REF_SELECTION_SPECIAL;
		dcs_on();
	}
	
	settings_set_home_ref();
	
	// TODO error handling
	
	// vd_clear_rect(help_layer, 0, 0, 128, 64);
	
	int i;
	
	for (i=0; i < 128; i++)
	{
		vd_set_pixel(help_layer, i, 56, 0, 1, 1);
	}
	
	
	
#define SIDEBOX_WIDTH 41
// #define SIDEBOX_HEIGHT 12
#define BOX1_YPOS 10
#define BOX2_YPOS 34
	
	for (i=0; i < 7; i++)
	{
		vd_set_pixel(help_layer, 32, 57+i, 0, 1, 1);
		vd_set_pixel(help_layer, 64, 57+i, 0, 1, 1);
		vd_set_pixel(help_layer, 96, 57+i, 0, 1, 1);
		vd_set_pixel(help_layer, SIDEBOX_WIDTH - 1, i, 0, 1, 1);
	}


	for (i=0; i < SIDEBOX_WIDTH; i++)
	{
		vd_set_pixel(help_layer, i, 7, 0, 1, 1);
	}
	
	/*
	for (i=0; i <= SIDEBOX_HEIGHT; i++)
	{
		vd_set_pixel(help_layer, 127-SIDEBOX_WIDTH, BOX1_YPOS+i, 0, 1, 1);
		vd_set_pixel(help_layer, 127-SIDEBOX_WIDTH, BOX2_YPOS+i, 0, 1, 1);
	}
	*/

	// vd_prints_xy(help_layer, 4, 58, VDISP_FONT_4x6, 0,"TEST");
	
	vd_prints_xy(VDISP_REF_LAYER, 0, 12, VDISP_FONT_6x8, 0, "Mode:");
	
	vd_printc_xy(VDISP_REF_LAYER, 120, 13, VDISP_FONT_8x12, 0, 0x1e); // arrow up
	vd_printc_xy(VDISP_REF_LAYER, 120, 39, VDISP_FONT_8x12, 0, 0x1f); // arrow up
	
	vd_printc_xy(VDISP_DVSET_LAYER, 120, 13, VDISP_FONT_8x12, 0, 0x1e); // arrow up
	vd_printc_xy(VDISP_DVSET_LAYER, 120, 39, VDISP_FONT_8x12, 0, 0x1f); // arrow up
	
	vd_printc_xy(VDISP_RMUSET_LAYER, 120, 13, VDISP_FONT_8x12, 0, 0x1e); // arrow up
	vd_printc_xy(VDISP_RMUSET_LAYER, 120, 39, VDISP_FONT_8x12, 0, 0x1f); // arrow up
	
	set_help_text();
}
示例#16
0
文件: dns2.c 项目: st0ne/up4dar-os
static void vDNSTask( void *pvParameters )
{
	uint16_t ttl_check_counter = 0;
	
	while(1)
	{
		int i;
		
		if (ttl_check_counter > 0)
		{
			ttl_check_counter --;
		}
		
		char entry_counter[2];
		entry_counter[0] = 0x30;
		entry_counter[1] = 0;
		
		for (i=0; i < DNS_NUMBER_OF_ENTRIES; i++)
		{
			vTaskDelay(DNS_WAIT_TIME_PER_SLOT); // give time to other threads
			
			struct dns2_cache * cur = dc + i;
			
			if (cur->reqname_len == 0) // skip inactive slots
				continue; 
			
			entry_counter[0] ++;
			
			if (cur->timeout > 0)
			{
				cur->timeout --;
			}
		
			switch (cur->state)
			{
			case DNS_STATE_REQ_A:
				if (cur->timeout == 0)
				{
					if (cur->retry > 0)
					{
						cur->retry --;
					}
				
					if (cur->retry == 0)
					{
						if (cur->primary_server != 0)
						{
							if (memcmp(ipv4_dns_sec, ipv4_zero_addr, sizeof ipv4_addr) == 0)
							{  // no secondary DNS server
								cur->state = DNS_STATE_RESULT_TIMEOUT;
							}
							else
							{
								cur->primary_server = 0; // try the secondary server
								cur->udp_local_port = 0; // with new port number
								cur->retry = DNS_REQ_RETRY;
							}
						}
						else
						{
							cur->state = DNS_STATE_RESULT_TIMEOUT;
						}
					}
					else
					{
						if (dns2_send_req(i, DNS_QTYPE_A) != 0)  // send failed
						{
							cur->state = DNS_STATE_RESULT_ERR;
						}
					}
				}
				break;
			
			}
			
			if (ttl_check_counter == 0)
			{
				if (cur->ttl > 0)
				{
					cur->ttl --;
				}
				
				if ((cur->ttl == 0) && (cur->link == 0)) // TTL expired and entry unused
				{
					cur->reqname_len = 0; // free entry
				}
			}
			
			
		} // for
		
		if (ttl_check_counter == 0)
		{
			ttl_check_counter = (DNS_TTL_COUNTER_TIMER / DNS_WAIT_TIME_PER_SLOT) / DNS_NUMBER_OF_ENTRIES; // decrease TTL every 3 seconds
		}
		
		vd_prints_xy(VDISP_DEBUG_LAYER, 0, 54, VDISP_FONT_4x6, 0, entry_counter);
		
	} // while(1)
}