Example #1
0
int main()
{
    Time planning;
    Time coding(2, 40);
    Time fixing(5, 55);
    Time total;

    std::cout << "planning time = ";
    planning.Show();
    std::cout << std::endl;

    std::cout << "coding time = ";
    coding.Show();
    std::cout << std::endl;

    std::cout << "fixing time = ";
    fixing.Show();
    std::cout << std::endl;

    total = coding.Sum(fixing);
    std::cout << "coding.Sum(fixing) = ";
    total.Show();
    std::cout << std::endl;

    return 0;
}
/*********************************************************************************************************
 * Function Name: display
 * Description:  display a num in certain location
 * Parameters: loca - location, 3-2-1-0
 *             num - number to display
 * Return: None
*********************************************************************************************************/
void TTSDisplay::display(uchar loca, uchar dta)
{

    if(loca > 3 || loca < 0)return;

    dtaDisplay[loca] = dta;

    loca = 3-loca;

    uchar segData = coding(dta);
    
    start();                            //start signal sent to TM1637 from MCU
    writeByte(ADDR_FIXED);
    stop();
    
    start();
    writeByte(loca|0xc0);
    writeByte(segData);
    stop();
    
    start();
    writeByte(Cmd_Dispdisplay);
    stop();

}
Example #3
0
//display function.Write to full-screen.
void MyTM1637::display(int8_t DispData[],uint8_t DispFlag)
{
  int8_t SegData[4];
  uint8_t i;
  if(DispFlag == DISPLAY_FLAG_F)
  {
      for(i = 0;i < 4;i ++)
      {
        SegData[i] = DispData[i];
      }
  }
  if(DispFlag == DISPLAY_FLAG_B)
  {
      for(i = 0;i < 4;i ++)
      {
        SegData[3 - i] = DispData[i];
      }
  }
  coding(SegData,DispFlag);
  start();          //start signal sent to TM1637 from MCU
  writeByte(ADDR_AUTO);//
  stop();           //
  start();          //
  writeByte(Cmd_SetAddr);//
  for(i=0;i < 4;i ++)
  {
    writeByte(SegData[i]);        //
  }
  stop();           //
  start();          //
  writeByte(Cmd_DispCtrl);//
  stop();           //
}
//******************************************
void Me7SegmentDisplay::display(uint8_t BitAddr, int8_t DispData)
{
    int8_t SegData;

    if((DispData >= 'A' && DispData <= 'F'))DispData = DispData - 'A' + 10;
    else if((DispData >= 'a' && DispData <= 'f'))DispData = DispData - 'a' + 10;
    SegData = coding(DispData);
    write(BitAddr, SegData); //
}
/**
 * \par Function
 *    display
 * \par Description
 *    Display 8 bit number array.
 * \param[in]
 *    DispData[] - The data that needs to be displayed store in this array.
 * \par Output
 *    None
 * \return
 *    None
 * \par Others
 *    None
 */
void Me7SegmentDisplay::display(uint8_t DispData[])
{
  uint8_t SegData[4];
  uint8_t i;
  for (i = 0; i < 4; i++)
  {
    SegData[i] = DispData[i];
  }
  coding(SegData);
  write(SegData);
}
Example #6
0
__RSPacket* __RSPacketDataDecrypt(__RSPacket* packet, RSPacketCoding coding, RSPacketCodingType type, void* context)
{
    if (packet == nil || coding == nil) return packet;
    if (isCmdPacket(packet)) return packet;
    if (getEncryptType(packet) != type) return nil;
    BOOL result = coding(packet->payload.data, getPacketKeyPtr(packet), packet->header.dataLength, context);
    if (result == YES)
    {
        unMarkEncrypt(packet);
    }
    return packet;
}
Example #7
0
__RSPacket* __RSPacketDataEncrypt(__RSPacket* packet, RSPacketCoding coding, RSPacketCodingType type, const char key[32], void* context)
{
    if (packet == nil || coding == nil) return packet;
    if (isCmdPacket(packet)) return packet;
    BOOL result = coding(packet->payload.data, key, packet->header.dataLength, context);
    if (result == YES)
    {
        setEncryptType(packet, type);
        setPacketKey(packet, key);
        markEncrypt(packet);
    }
    return packet;
}
/**
 * \par Function
 *    display
 * \par Description
 *    Display data to certain digit.
 * \param[in]
 *    BitAddr - Address to display.
 * \param[in]
 *    DispData - Data to display.
 * \param[in]
 *    point_on - Display the point or not.
 * \par Output
 *    None
 * \return
 *    None
 * \par Others
 *    None
 */
void Me7SegmentDisplay::display(uint8_t BitAddr, uint8_t DispData, uint8_t point_on)
{
  uint8_t SegData;

  if ((DispData >= 'A' && DispData <= 'F'))
  {
    DispData = DispData - 'A' + 10;
  }
  else if ((DispData >= 'a' && DispData <= 'f'))
  {
    DispData = DispData - 'a' + 10;
  }
  if(point_on == POINT_ON )
  {
    SegData = coding(DispData+0x10);
  }
  else
  {
    SegData = coding(DispData);
  }
  write(BitAddr, SegData);
}
Example #9
0
//******************************************
void TM1637::display(uint8_t BitAddr,int8_t DispData)
{
  int8_t SegData;
  SegData = coding(DispData);
  start();          //start signal sent to TM1637 from MCU
  writeByte(ADDR_FIXED);//
  stop();           //
  start();          //
  writeByte(BitAddr|0xc0);//
  writeByte(SegData);//
  stop();            //
  start();          //
  writeByte(Cmd_DispCtrl);//
  stop();           //
}
//******************************************
void TM1637::display(uint8_t bit_addr, int8_t disp_data)
{
  int8_t seg_data;

  seg_data = coding(disp_data);
  start();               // Start signal sent to TM1637 from MCU
  writeByte(ADDR_FIXED); // Command1: Set data
  stop();
  start();
  writeByte(bit_addr | 0xc0); // Command2: Set data (fixed address)
  writeByte(seg_data);        // Transfer display data 8 bits
  stop();
  start();
  writeByte(cmd_disp_ctrl); // Control display
  stop();
}
Example #11
0
//******************************************
void MyTM1637::display(uint8_t BitAddr,int8_t DispData,uint8_t DispFlag)
{
  int8_t SegData;
  SegData = coding(DispData,DispFlag);
  start();          //start signal sent to TM1637 from MCU
  writeByte(ADDR_FIXED);//
  stop();           //
  start();          //
  if(DispFlag == DISPLAY_FLAG_F)writeByte(BitAddr|0xc0);//
  if(DispFlag == DISPLAY_FLAG_B)writeByte((3 - BitAddr)|0xc0);//
  writeByte(SegData);//
  stop();            //
  start();          //
  writeByte(Cmd_DispCtrl);//
  stop();           //
}
Example #12
0
int main()
{
	Time planning;
	Time coding(2, 40);
	Time fixing(5, 55);
	Time total;

	std::cout << "planning: ";
	planning.Show();
	std::cout << "coding: ";
	coding.Show();
	std::cout << "fixing: ";
	fixing.Show();
	std::cout << "total: ";
	total = coding + fixing;
	total.Show();

	Time morefixing(3, 28);
	std::cout << "more fixing: ";
	morefixing.Show();

	std::cout << "total: ";
	total = total + morefixing;
	total.Show();

	std::cout << "operator+():\n";
	total = total.operator+(morefixing);
	total.Show();
	std::cout << total;	//przeci¹¿ona wersja '<<' zwracaj¹ca referencjê do ostream

	std::ofstream fout;
	fout.open("tst.txt");
	std::cout << "overloading <<:\n";
	operator<<(std::cout, total);	//lub tak: std::cout << total;
	fout << total;					//lub tak: operator<<(fout, total);
	//fout.close();

	Time something(2, 40);
	Time res;
	res = operator*(2.5, something);
	operator<<(fout, res);
	fout.close();
	return 0;
}
void zip_file(string file_name)
{
    vector<tree_nodes<char>*> the_sons;
    tree_nodes<char>* the_tree;
    std::fstream in(file_name);
    std::istreambuf_iterator<char> beg(in), end;
    std::string the_file(beg, end);
    stat(the_file,counting);
    the_sons=build_sons(counting);
    the_tree=huffman_tree(the_sons);
	for (int i=0; i<128;i++)
    {
        if (counting[i]!=0)
        {
        std::string temp_code="";
        code[i]=get_the_code((char) i , temp_code , the_tree);
		}
    }
	
    coding(code,the_file);
}
// Display function.Write to full-screen.
void TM1637::display(int8_t disp_data[])
{
  int8_t seg_data[DIGITS];
  uint8_t i;

  for (i = 0; i < DIGITS; i++)
    seg_data[i] = disp_data[i];

  coding(seg_data);
  start();              // Start signal sent to TM1637 from MCU
  writeByte(ADDR_AUTO); // Command1: Set data
  stop();
  start();
  writeByte(cmd_set_addr); // Command2: Set address (automatic address adding)

  for (i = 0; i < DIGITS; i++)
    writeByte(seg_data[i]); // Transfer display data (8 bits x num_of_digits)

  stop();
  start();
  writeByte(cmd_disp_ctrl); // Control display
  stop();
}
Example #15
0
//display function.Write to full-screen.
void TM1637::display(int8_t DispData[])
{
  int8_t SegData[4];
  uint8_t i;
  for(i = 0;i < 4;i ++)
  {
    SegData[i] = DispData[i];
  }
  coding(SegData);
  start();          //start signal sent to TM1637 from MCU
  writeByte(ADDR_AUTO);//
  stop();           //
  start();          //
  writeByte(Cmd_SetAddr);//
  for(i=0;i < 4;i ++)
  {
    writeByte(SegData[i]);        //
  }
  stop();           //
  start();          //
  writeByte(Cmd_DispCtrl);//
  stop();           //
}
// -----------------------------------------------------------------------------
// CWPPushMessage::ParseContentType
// -----------------------------------------------------------------------------
//
void CWPPushMessage::ParseContentType( TLex8& aPointer )
    {
    // Go through the whole content type header.
    while( !aPointer.Eos() )
        {
        // Each parameter might be well-known (integer) or unknown (text)
        if( IsIntegerValue( aPointer ) )
            {
            // For well-known parameters, the token is an integer value
            TUint paramToken( I64LOW( GetIntegerValue( aPointer ) ) );

            // These are filled with results from parsing.
            TInt resultInteger( 0 );
            TPtrC8 resultString;
            
            // Make sure paramToken fits into KParameterTypes table
            if( paramToken 
                < sizeof(KParameterTypes)/sizeof(TParameterCodingType))
                {
                // Get the coding and use it to determine how we should decode 
                // the next parameter value. We actually ignore all results 
                // except short integer (SEC) and text-value (MAC), but the 
                // rest of the parameters have to be parsed anyway.
                TParameterCodingType coding( KParameterTypes[paramToken] );

                switch( coding )
                    {
                    case EQValue:
                        GetQValue( aPointer );
                        break;

                    case EWellKnownCharset:
                        GetWellKnownCharset( aPointer );
                        break;

                    case EVersionValue:
                        GetVersionValue( aPointer );
                        break;

                    case EIntegerValue:
                        GetIntegerValue( aPointer );
                        break;

                    case ETextString:
                        GetTextString( aPointer );
                        break;

                    case EFieldName:
                        GetFieldName( aPointer );
                        break;

                    case EShortInteger:
                        resultInteger = GetShortInteger( aPointer );
                        break;

                    case EConstrainedEncoding:
                        GetConstrainedEncoding( aPointer );
                        break;

                    case EDeltaSecondsValue:
                        GetDeltaSecondsValue( aPointer );
                        break;

                    case ENoValue:
                        GetNoValue( aPointer );
                        break;

                    case ETextValue:
                        resultString.Set( GetTextValue( aPointer ) );
                        break;

                    case EDateValue:
                        GetDateValue( aPointer );
                        break;

                    default:
                        break;
                    }

                // We have a result. We're actually only interested in
                // SEC and MAC parameters, so we save them here.
                switch( paramToken )
                    {
                    case KWSPHeaderSEC:
                        iSEC = resultInteger;
                        break;

                    case KWSPHeaderMAC:
                        iMAC.Set( resultString );
                        break;

                    default:
                        break;
                    }
                }
            }
        else
            {
            // Unknown parameter. Its name is in text, and the value
            // might be an integer or text.
            GetTokenText( aPointer );
            if( IsIntegerValue( aPointer ) )
                {
                GetIntegerValue( aPointer );
                }
            else
                {
                GetTextValue( aPointer );
                }
            }
        }
    }
void TM1637::coding(int8_t disp_data[])
{
  for (uint8_t i = 0; i < DIGITS; i++)
    disp_data[i] = coding(disp_data[i]);
}