Esempio n. 1
0
      bool get_next_bid()
      { try {
         if( _current_bid && _current_bid->get_quantity().amount > 0 )
            return _current_bid.valid();

         ++_orders_filled;
         _current_bid.reset();

         if( _bid_itr.valid() )
         {
            auto bid = market_order( bid_order, _bid_itr.key(), _bid_itr.value() );
            if( bid.get_price().quote_asset_id == _quote_id &&
                bid.get_price().base_asset_id == _base_id )
            {
                if( bid.get_price() < _market_stat.center_price && get_next_short() )
                {
                   return _current_bid.valid();
                }

                _current_bid = bid;
                --_bid_itr;
                return _current_bid.valid();
            }
         }
         get_next_short();
         return _current_bid.valid();
      } FC_CAPTURE_AND_RETHROW() }
static bool scr_notifications_handle_button_pressed(uint32_t button_id) {
	  switch (button_id) {
			  case SCR_EVENT_PARAM_BUTTON_BACK:
						scr_mngr_close_notifications();
				    return true;
			  case SCR_EVENT_PARAM_BUTTON_UP:
				{
						uint32_t read_address = notifications_get_current_data();
						uint8_t notification_type = get_next_byte(&read_address);
	
						if (notification_type != NOTIFICATIONS_CATEGORY_SUMMARY) {
								uint16_t notification_id = get_next_short(&read_address);
								uint8_t page = get_next_byte(&read_address);
								if (page > 0) {
										notifications_prev_part(notification_id, page);
								}
						}
				}
				    return true;
			  case SCR_EVENT_PARAM_BUTTON_DOWN:
				{
					
						uint32_t read_address = notifications_get_current_data();
						uint8_t notification_type = get_next_byte(&read_address);
	
						if (notification_type == NOTIFICATIONS_CATEGORY_SUMMARY) {
								//show first
								notifications_invoke_function(NOTIFICATIONS_SHOW_FIRST);
						} else {
								uint16_t notification_id = get_next_short(&read_address);
								uint8_t page = get_next_byte(&read_address);
								uint8_t font = get_next_byte(&read_address);
								bool has_more = get_next_byte(&read_address);
								if (has_more) {
										notifications_next_part(notification_id, page);
								} else {
										notifications_next(notification_id);
								}
						}
				}
				    return true;
			  case SCR_EVENT_PARAM_BUTTON_SELECT:
				{
						uint32_t read_address = notifications_get_current_data();
						uint8_t notification_type = get_next_byte(&read_address);
	
						if (notification_type != NOTIFICATIONS_CATEGORY_SUMMARY) {
								uint16_t notification_id = get_next_short(&read_address);
								notifications_open(notification_id);
						}
				}
				    return true;
		}
		return false;
}
static void scr_notifications_draw_screen() {
		uint32_t read_address = notifications_get_current_data();
    uint8_t notification_type = get_next_byte(&read_address);
	
		switch(notification_type) {
				case NOTIFICATIONS_CATEGORY_MESSAGE:
				case NOTIFICATIONS_CATEGORY_EMAIL:
				case NOTIFICATIONS_CATEGORY_SOCIAL:
				case NOTIFICATIONS_CATEGORY_ALARM:
				case NOTIFICATIONS_CATEGORY_INCOMING_CALL:
				case NOTIFICATIONS_CATEGORY_OTHER:
				{
						uint16_t notification_id = get_next_short(&read_address);
						uint8_t page = get_next_byte(&read_address);
						uint8_t font = get_next_byte(&read_address);
						bool has_more = get_next_byte(&read_address);
					
						char* data_ptr = (char*)(0x80000000 + read_address);
						mlcd_draw_text(data_ptr, 3, 3,  MLCD_XRES - 6, MLCD_YRES - 6, font, HORIZONTAL_ALIGN_LEFT | MULTILINE);
				}
						break;
				case NOTIFICATIONS_CATEGORY_SUMMARY:
				{
						uint8_t notification_count = get_next_byte(&read_address);
				
						if (notification_count>9) {
								notification_count = 9;
						}
						mlcd_draw_digit(notification_count, 20, 20, MLCD_XRES-40, MLCD_YRES-40, 11);
				}
						break;
		}
}
	/*
static void draw_incmonig_call_notification() {
	  uint32_t read_address = m_address + 1;
    uint16_t param_1_offset = get_next_short(&read_address);
    uint16_t param_2_offset = get_next_short(&read_address);
	
	  mlcd_draw_text(I18N_TRANSLATE(MESSAGE_INCOMING_CALL), 0, 5, MLCD_XRES, 20, FONT_OPTION_NORMAL, ALIGN_CENTER);
	
	  uint8_t data[32];
		read_address = m_address + param_1_offset;
	  ext_ram_read_data(read_address, data, 32);
	  mlcd_draw_text((char*)data, 0, 60, MLCD_XRES, 20, FONT_OPTION_NORMAL, ALIGN_CENTER);
	
		read_address = m_address + param_2_offset;
	  ext_ram_read_data(read_address, data, 32);
	  mlcd_draw_text((char*)data, 0, 90, MLCD_XRES, 20, FONT_OPTION_NORMAL, ALIGN_CENTER);
}
*/
static void draw_default_notification() {
	  uint32_t read_address = m_address + 1;
    uint16_t text_offset = get_next_short(&read_address);
    uint8_t font = get_next_byte(&read_address);
    uint8_t operationsNo = get_next_byte(&read_address);
		uint16_t op1_name_offset = operationsNo>0?get_next_short(&read_address):0;
	  uint16_t op2_name_offset = operationsNo>1?get_next_short(&read_address):0;
	
		char* data_ptr = (char*)(0x80000000 + m_address + text_offset);
	  mlcd_draw_text(data_ptr, 3, 30, MLCD_XRES - 6, MLCD_YRES-60, font, HORIZONTAL_ALIGN_CENTER | MULTILINE | VERTICAL_ALIGN_CENTER);

		if (op1_name_offset != 0) {
				data_ptr = (char*)(0x80000000 + m_address + op1_name_offset);
				mlcd_draw_text(data_ptr, 3, 0, MLCD_XRES-6, 30, font, HORIZONTAL_ALIGN_RIGHT | VERTICAL_ALIGN_CENTER);
		}
		
		if (op2_name_offset != 0) {
				data_ptr = (char*)(0x80000000 + m_address + op2_name_offset);
				mlcd_draw_text(data_ptr, 3, MLCD_YRES-30, MLCD_XRES-6, 30, font, HORIZONTAL_ALIGN_RIGHT | VERTICAL_ALIGN_CENTER);
		}
}
static bool scr_notifications_handle_button_long_pressed(uint32_t button_id) {
	  switch (button_id) {
			  case SCR_EVENT_PARAM_BUTTON_DOWN:
				{
						uint32_t read_address = notifications_get_current_data();
						uint8_t notification_type = get_next_byte(&read_address);
						if (notification_type != NOTIFICATIONS_CATEGORY_SUMMARY) {
								uint16_t notification_id = get_next_short(&read_address);
								notifications_next(notification_id);
						}				
				}
				    return true;
		}
		return false;
}