Exemple #1
0
int playback_get_length (void)
{
    g_return_val_if_fail (playing, 0);
    wait_until_ready ();

    return current_length;
}
Exemple #2
0
/**
 * 写命令
 * @param[in] Command 命令
 * @param[in] busyFlag 是否检查繁忙
 */
void set_command(uint8_t data, uint8_t busyFlag)
{
    uint8_t busy;
    busy = busyFlag;
    //busy=1 表示系统希望检测忙信号
    if (busy==1)
        //等待指令执行完毕
        wait_until_ready();
    //完毕,可以写了
    SET_DB_OUT()
    ;
    RW_W;     //置为写状态 =写 0
    RS_L;     //写入的是命令字 =指令
    En_H;
    (data&0b00010000) ? (DB4_DAT |= _BV(DB4)) : (DB4_DAT &= ~_BV(DB4));     //第4位
    (data&0b00100000) ? (DB5_DAT |= _BV(DB5)) : (DB5_DAT &= ~_BV(DB5));     //第5位
    (data&0b01000000) ? (DB6_DAT |= _BV(DB6)) : (DB6_DAT &= ~_BV(DB6));     //第6位
    (data&0b10000000) ? (DB7_DAT |= _BV(DB7)) : (DB7_DAT &= ~_BV(DB7));     //第7位
    _delay_us(25);
    en_toggle();     //产生使能脉冲,使之在下降沿开始执行指令
    (data&0b00000001) ? (DB4_DAT |= _BV(DB4)) : (DB4_DAT &= ~_BV(DB4));     //第0位
    (data&0b00000010) ? (DB5_DAT |= _BV(DB5)) : (DB5_DAT &= ~_BV(DB5));     //第1位
    (data&0b00000100) ? (DB6_DAT |= _BV(DB6)) : (DB6_DAT &= ~_BV(DB6));     //第2位
    (data&0b00001000) ? (DB7_DAT |= _BV(DB7)) : (DB7_DAT &= ~_BV(DB7));     //第3位
    _delay_us(25);
    en_toggle();     //产生使能脉冲,使之在下降沿开始执行指令
}
Exemple #3
0
/**
 * 读数据
 * 读当前AC地址的字符的值,
 * @note 4位模式先传高4位,再传低4位
 * @return
 */
uint8_t get_data(void)
{
    uint8_t data = 0;
    wait_until_ready();     //等待指令执行完毕
    //LCDDDR = 0x00;     //数据总线位输入
    SET_DB_IN()
    ;
    RW_R;     //读 Hi
    RS_DAT;     //数据 Hi
    En_L;
    DelaytE;
    En_H;     //触发
    DelaytE;
    //data = PIND;
    //先传高四位
    (DB4_IN &_BV(DB4)) ? (data |= _BV(4)) : (data &= ~_BV(4));
    (DB5_IN &_BV(DB5)) ? (data |= _BV(5)) : (data &= ~_BV(5));
    (DB6_IN &_BV(DB6)) ? (data |= _BV(6)) : (data &= ~_BV(6));
    (DB7_IN &_BV(DB7)) ? (data |= _BV(7)) : (data &= ~_BV(7));
    En_L;
    DelaytE;
    En_H;     //触发
    DelaytE;     // 这是忙标志被映射到数据DB7 位
    (DB4_IN &_BV(DB4)) ? (data |= _BV(0)) : (data &= ~_BV(0));
    (DB5_IN &_BV(DB5)) ? (data |= _BV(1)) : (data &= ~_BV(1));
    (DB6_IN &_BV(DB6)) ? (data |= _BV(2)) : (data &= ~_BV(2));
    (DB7_IN &_BV(DB7)) ? (data |= _BV(3)) : (data &= ~_BV(3));
    //En_L;
    return data;
}
Exemple #4
0
char * playback_get_title (void)
{
    g_return_val_if_fail (playing, NULL);
    wait_until_ready ();

    char s[32];

    if (current_length)
    {
        int len = current_length / 1000;

        if (len < 3600)
            snprintf (s, sizeof s, get_bool (NULL, "leading_zero") ?
             " (%02d:%02d)" : " (%d:%02d)", len / 60, len % 60);
        else
            snprintf (s, sizeof s, " (%d:%02d:%02d)", len / 3600, (len / 60) %
             60, len % 60);
    }
    else
        s[0] = 0;

    if (get_bool (NULL, "show_numbers_in_pl"))
        return str_printf ("%d. %s%s", 1 + playlist_get_position
         (playlist_get_playing ()), current_title, s);

    return str_printf ("%s%s", current_title, s);
}
Exemple #5
0
/**
 * 这个暂时不知道是读的什么东西,好像是字符的点阵的值,一行8个点那个 @note
 * @return
 */
uint8_t get_pos2(void)
{
    uint8_t data = 0;
    wait_until_ready();     //等待指令执行完毕
    //LCDDDR = 0x00;     //数据总线位输入
    SET_DB_IN()
    ;
    RW_R;     //读 HI
    RS_DAT;  //地址 0
    DelaytE;
    En_H;     //触发
    DelaytE;
    //先传位置低4位
    (DB4_IN &_BV(DB4)) ? (data |= _BV(0)) : (data &= ~_BV(0));
    (DB5_IN &_BV(DB5)) ? (data |= _BV(1)) : (data &= ~_BV(1));
    (DB6_IN &_BV(DB6)) ? (data |= _BV(2)) : (data &= ~_BV(2));
    (DB7_IN &_BV(DB7)) ? (data |= _BV(3)) : (data &= ~_BV(3));
    En_L;
    DelaytE;
    En_H;     //触发
    DelaytE;
    //在传高4位
    (DB4_IN &_BV(DB4)) ? (data |= _BV(4)) : (data &= ~_BV(4));
    (DB5_IN &_BV(DB5)) ? (data |= _BV(5)) : (data &= ~_BV(5));
    (DB6_IN &_BV(DB6)) ? (data |= _BV(6)) : (data &= ~_BV(6));
    (DB7_IN &_BV(DB7)) ? (data |= _BV(7)) : (data &= ~_BV(7));
    return data;
}
int
NdbRestarter::restartNodes(int * nodes, int cnt,
                           Uint32 flags)
{
  if (!isConnected())
    return -1;

  int ret = 0;
  int unused;
  if ((ret = ndb_mgm_restart4(handle, cnt, nodes,
                              (flags & NRRF_INITIAL),
                              (flags & NRRF_NOSTART),
                              (flags & NRRF_ABORT),
                              (flags & NRRF_FORCE),
                              &unused)) <= 0)
  {
    /**
     * ndb_mgm_restart4 returned error, one reason could
     * be that the node have not stopped fast enough!
     * Check status of the node to see if it's on the 
     * way down. If that's the case ignore the error
     */ 

    if (getStatus() != 0)
      return -1;

    g_info << "ndb_mgm_restart4 returned with error, checking node state"
           << endl;

    for (int j = 0; j<cnt; j++)
    {
      int _nodeId = nodes[j];
      for(unsigned i = 0; i < ndbNodes.size(); i++)
      {
        if(ndbNodes[i].node_id == _nodeId)
        {
          g_info <<_nodeId<<": status="<<ndbNodes[i].node_status<<endl;
          /* Node found check state */
          switch(ndbNodes[i].node_status){
          case NDB_MGM_NODE_STATUS_RESTARTING:
          case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
            break;
          default:
            MGMERR(handle);
            g_err  << "Could not stop node with id = "<< _nodeId << endl;
            return -1;
          }
        }
      }
    }
  }

  if ((flags & NRRF_NOSTART) == 0)
  {
    wait_until_ready(nodes, cnt);
  }

  return 0;
}
Exemple #7
0
void playback_get_info (int * bitrate, int * samplerate, int * channels)
{
    g_return_if_fail (playing);
    wait_until_ready ();

    * bitrate = current_bitrate;
    * samplerate = current_samplerate;
    * channels = current_channels;
}
int 
NdbRestarter::waitClusterStarted(unsigned int _timeout){
  int res = waitClusterState(NDB_MGM_NODE_STATUS_STARTED, _timeout);
  if (res == 0)
  {
    wait_until_ready();
  }
  return res;
}
void UniversalAdapter::setCursor(uint8_t col, uint8_t row)
{
    SPIFrame sf(this); // asserts cs on entry and deasserts on exit
    wait_until_ready();
    uint8_t cmd = SET_CURSOR | 1;
    uint8_t rc = (row << 5) | (col & 0x1F);
    writeSPI(cmd);
    writeSPI(rc);
}
int NdbRestarter::waitNodesStarted(const int * _nodes, int _num_nodes,
		     unsigned int _timeout){
  int res = waitNodesState(_nodes, _num_nodes,
                           NDB_MGM_NODE_STATUS_STARTED, _timeout);
  if (res == 0)
  {
    wait_until_ready(_nodes, _num_nodes);
  }

  return res;
}
Exemple #11
0
void playback_stop (void)
{
    g_return_if_fail (playing);
    wait_until_ready ();

    if (current_decoder)
        current_decoder->stop (& playback_api);

    playback_cleanup ();
    complete_stop ();
}
void UniversalAdapter::write(const char *line, int len)
{
    SPIFrame sf(this); // asserts cs on entry and deasserts on exit
    wait_until_ready();
    if(len > 31) {
        // this is the limit the UPA can handle in one frame (31 bytes)
        len = 31;
    }
    uint8_t cmd = LCD_WRITE | (len & 0x1F);
    writeSPI(cmd);
    for (int i = 0; i < len; ++i) {
        writeSPI(*line++);
    }
}
Exemple #13
0
int playback_get_time (void)
{
    g_return_val_if_fail (playing, 0);
    wait_until_ready ();

    int time = -1;

    if (current_decoder && current_decoder->get_time)
        time = current_decoder->get_time (& playback_api);

    if (time < 0)
        time = output_get_time ();

    return time - time_offset;
}
Exemple #14
0
void playback_pause (void)
{
    g_return_if_fail (playing);
    wait_until_ready ();

    if (! current_decoder || ! current_decoder->pause)
        return;

    paused = ! paused;
    current_decoder->pause (& playback_api, paused);

    if (paused)
        hook_call ("playback pause", NULL);
    else
        hook_call ("playback unpause", NULL);
}
Exemple #15
0
void playback_seek (int time)
{
    g_return_if_fail (playing);
    wait_until_ready ();

    if (! current_decoder || ! current_decoder->mseek || current_length < 1)
        return;

    current_decoder->mseek (& playback_api, time_offset + CLAMP (time, 0,
     current_length));

    /* If the plugin is using our output system, don't call "playback seek"
     * immediately but wait for output_set_time() to be called.  This ensures
     * that a "playback seek" handler can call playback_get_time() and get the
     * new time. */
    if (! output_is_open ())
        hook_call ("playback seek", NULL);
}
Exemple #16
0
void ifmode( bs_ifm m )
{
    int ready = 0;

    if ( m == BS_IFM_REG )
    {
        set_gpio_val( GPIO_CNF1, 0 );
    }
    else
    {
        set_gpio_val( GPIO_CNF1, 1 );
    }

    while (ready == 0)
    {
        reset();
        ready = wait_until_ready();
    }
}
Exemple #17
0
int main(int argc, char** argv)
{
	int released;
	lt_t delay = ms2ns(1000);
	int wait = 0;
	int expected = 0;
	int opt;
      
	while ((opt = getopt(argc, argv, OPTSTR)) != -1) {
		switch (opt) {
		case 'd':
			delay = ms2ns(atoi(optarg));
			break;
		case 'w':
			wait = 1;
			break;
		case 'f':
			wait = 1;
			expected = atoi(optarg);
			break;
		case ':':
			usage("Argument missing.");
			break;
		case '?':
		default:
			usage("Bad argument.");
			break;
		}
	}

	if (wait)
		wait_until_ready(expected);

	released = release_ts(&delay);
	if (released < 0) {
		perror("release task system");
		exit(1);
	}
	
	printf("Released %d real-time tasks.\n", released);

	return 0;
}
// Sets the indicator leds
void UniversalAdapter::setLed(int led, bool onoff)
{
    SPIFrame sf(this); // asserts cs on entry and deasserts on exit
    if(onoff) {
        switch(led) {
            case LED_FAN_ON: ledBits    |= 1; break; // on
            case LED_HOTEND_ON: ledBits |= 2; break; // on
            case LED_BED_ON: ledBits    |= 4; break; // on
        }
    } else {
        switch(led) {
            case LED_FAN_ON: ledBits    &= ~1; break; // off
            case LED_HOTEND_ON: ledBits &= ~2; break; // off
            case LED_BED_ON: ledBits    &= ~4; break; // off
        }
    }
    uint8_t cmd = SET_LEDS | 1;
    wait_until_ready();
    writeSPI(cmd);
    writeSPI(ledBits);
}
Exemple #19
0
/**
 * 写数据
 * @param data
 */
void set_data(uint8_t data)
{
    wait_until_ready();     //等待指令执行完毕
    //LCDDDR = 0xff;     //数据总线位输出
    SET_DB_OUT()
    ;
    RW_W;     //置为写状态
    RS_H;     //写入的是数据
    En_H;
    (data&0b00010000) ? (DB4_DAT |= _BV(DB4)) : (DB4_DAT &= ~_BV(DB4));     //第4位
    (data&0b00100000) ? (DB5_DAT |= _BV(DB5)) : (DB5_DAT &= ~_BV(DB5));     //第5位
    (data&0b01000000) ? (DB6_DAT |= _BV(DB6)) : (DB6_DAT &= ~_BV(DB6));     //第6位
    (data&0b10000000) ? (DB7_DAT |= _BV(DB7)) : (DB7_DAT &= ~_BV(DB7));     //第7位
    //_delay_us(25);
    en_toggle();     //产生使能脉冲,使之在下降沿开始执行指令
    (data&0b00000001) ? (DB4_DAT |= _BV(DB4)) : (DB4_DAT &= ~_BV(DB4));     //第0位
    (data&0b00000010) ? (DB5_DAT |= _BV(DB5)) : (DB5_DAT &= ~_BV(DB5));     //第1位
    (data&0b00000100) ? (DB6_DAT |= _BV(DB6)) : (DB6_DAT &= ~_BV(DB6));     //第2位
    (data&0b00001000) ? (DB7_DAT |= _BV(DB7)) : (DB7_DAT &= ~_BV(DB7));     //第3位
    //_delay_us(25);
    en_toggle();     //产生使能脉冲,使之在下降沿开始执行指令
}
// cycle the buzzer pin at a certain frequency (hz) for a certain duration (ms)
void UniversalAdapter::buzz(long duration, uint16_t freq)
{
    SPIFrame sf(this); // asserts cs on entry and deasserts on exit
    wait_until_ready();
    writeSPI(BUZZ);
}
void UniversalAdapter::clear()
{
    SPIFrame sf(this); // asserts cs on entry and deasserts on exit
    wait_until_ready();
    writeSPI(LCD_CLEAR);
}