예제 #1
0
I18N_PLAY_FUNCTION(en, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
  if (number < 0) {
    PUSH_NUMBER_PROMPT(EN_PROMPT_MINUS);
    number = -number;
  }

  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
    unit++;
  }

  int8_t mode = MODE(att);
  if (mode > 0) {
    // we assume that we are PREC1
    div_t qr = div(number, 10);
    if (qr.rem) {
      PLAY_NUMBER(qr.quot, 0, 0);
      PUSH_NUMBER_PROMPT(EN_PROMPT_POINT_BASE + qr.rem);
      number = -1;
    }
    else {
      number = qr.quot;
    }
  }

  int16_t tmp = number;

  if (number >= 1000) {
    PLAY_NUMBER(number / 1000, 0, 0);
    PUSH_NUMBER_PROMPT(EN_PROMPT_THOUSAND);
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    PUSH_NUMBER_PROMPT(EN_PROMPT_HUNDRED + (number/100)-1);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  if (number >= 0) {
    PUSH_NUMBER_PROMPT(EN_PROMPT_ZERO + number);
  }
  
  if (unit) {
    EN_PUSH_UNIT_PROMPT(tmp, EN_PROMPT_UNITS_BASE + unit*2);
  }
}
예제 #2
0
파일: tts_cz.cpp 프로젝트: kamnxt/opentx
I18N_PLAY_FUNCTION(cz, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{

  if (number < 0) {
    PUSH_NUMBER_PROMPT(CZ_PROMPT_MINUS);
    number = -number;
  }

#if !defined(CPUARM)
  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
    unit++;
  }
#endif

  int8_t mode = MODE(att);
  if (mode > 0) {
#if defined(CPUARM)
    if (mode == 2) {
      number /= 10;
    }
#else
    // we assume that we are PREC1
#endif
    div_t qr = div(number, 10);   
      if (qr.rem) {
        PLAY_NUMBER(qr.quot, 0, ZENSKY);
        if (qr.quot == 0)
          PUSH_NUMBER_PROMPT(CZ_PROMPT_CELA);
        else
          CZ_PUSH_UNIT_PROMPT(qr.quot, CZ_PROMPT_CELA);
        PLAY_NUMBER(qr.rem, 0, ZENSKY);
        PUSH_NUMBER_PROMPT(CZ_PROMPT_UNITS_BASE+((unit-1)*4)+3);
        return;
      }
      else
        number = qr.quot;
  }

  int16_t tmp = number;
  
  switch(unit) {
    case 0:
      break;
    case 4:
    case 10:
    case 13:
    case 15:
    case 16:
    case 17:
    case 18:
      att = ZENSKY;
      break;
    case 8:
    case 19:
      att = STREDNI;
      break;
    default:
      att = MUZSKY;
      break;
  }

  if ((number == 1) && (att == MUZSKY)) {
    PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDEN);
    number = -1;
  }
  
  if ((number == 1) && (att == STREDNI)) {
    PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDNO);
    number = -1;
  }
  
  if ((number == 2) && ((att == ZENSKY) || (att == STREDNI))) {
    PUSH_NUMBER_PROMPT(CZ_PROMPT_DVE);
    number = -1;
  }
  
  if (number >= 1000) {
    if (number >= 2000) 
      PLAY_NUMBER(number / 1000, 0, 0);
    if (number >= 2000 && number < 5000)
      PUSH_NUMBER_PROMPT(CZ_PROMPT_TISICE);
    else
      PUSH_NUMBER_PROMPT(CZ_PROMPT_TISIC);
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    PUSH_NUMBER_PROMPT(CZ_PROMPT_STO + (number/100)-1);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  
  if (number >= 0) {
    PUSH_NUMBER_PROMPT(CZ_PROMPT_NULA+number);
  }

  if (unit) {
    CZ_PUSH_UNIT_PROMPT(tmp, (CZ_PROMPT_UNITS_BASE+((unit-1)*4)));
  }
}
예제 #3
0
파일: tts_pl.cpp 프로젝트: Plohish/opentx
I18N_PLAY_FUNCTION(pl, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{

  if (number < 0) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_MINUS);
    number = -number;
  }

  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
#if defined(CPUARM)
    if ((att & PREC1) && (unit == UNIT_FEET || (unit == UNIT_DIST && number >= 100))) {
      number = div10_and_round(number);
      att -= PREC1;
    }
#endif
    unit++;
  }

  int8_t mode = MODE(att);
  if (mode > 0) {
    // we assume that we are PREC1
    div_t qr = div(number, 10);   
      if (qr.rem) {
        PLAY_NUMBER(qr.quot, 0, ZENSKI);
        if (qr.quot == 0)
          PUSH_NUMBER_PROMPT(PL_PROMPT_CALA);
        else
          PL_PUSH_UNIT_PROMPT(qr.quot, PL_PROMPT_CALA);
        PLAY_NUMBER(qr.rem, 0, ZENSKI);
        PUSH_NUMBER_PROMPT(PL_PROMPT_UNITS_BASE+((unit-1)*4)+3);
        return;
      }
      else
        number = qr.quot;
  }

  int16_t tmp = number;
  
  switch(unit) {
    case 0:
      break;
    case 10:
    case 13:
    case 15:
    case 16:
    case 17:
      att = ZENSKI;
      break;
    case 100:
      att = NIJAKI;
      break;
    default:
      att = MESKI;
      break;
  }

  if ((number == 1) && (att == ZENSKI)) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_JEDNA);
    number = -1;
  }
  
  if ((number == 1) && (att == NIJAKI)) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_JEDNO);
    number = -1;
  }
  
  if ((number == 2) && (att == ZENSKI)) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_DWIE);
    number = -1;
  }
  




  if (number >= 1000) {
    if (number >= 2000) 
      PLAY_NUMBER(number / 1000, 0, 0);
    if (number >= 2000 && number < 5000)
      PUSH_NUMBER_PROMPT(PL_PROMPT_TISIACE);
    else
      PUSH_NUMBER_PROMPT(PL_PROMPT_TISIAC);
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_STO + (number/100)-1);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  
  if (number >= 0) {
    int test_2 =0;
    test_2 =number % 10;
    int ten=0;
    ten=(number - (number % 10))/10;
    if (att == ZENSKI && test_2==2 && ten >= 2 ) {
      
      PUSH_NUMBER_PROMPT(PL_PROMPT_DZIESIATKI_ZENSKIE+ten);
    }else 
       PUSH_NUMBER_PROMPT(PL_PROMPT_ZERO+number);
  }

  if (unit) {
    PL_PUSH_UNIT_PROMPT(tmp, (PL_PROMPT_UNITS_BASE+((unit-1)*4)));
  }
}
예제 #4
0
getvalue_t getConvertedTelemetryValue(getvalue_t val, uint8_t unit)
{
  convertUnit(val, unit);
  return val;
}
예제 #5
0
TTErr TTData::setIntegerDecimalArrayValue(const TTValue& value)
{
	// Storing locally to protect the input value
	TTValue lValue = value;
	
	if (!mIsSending && mActive)
    {
		// We are locking while updating, in order to prevent returned values from clients to cause an infinite loop.
		mIsSending = YES;
		
		if (checkIntegerDecimalArrayType(lValue))
        {
			if (lValue.size() > 0)
            {
				TTValue lPreviousValue = mValue;
				
				// If ramp is performed using non-default dataspace unit, the returned values need to be converted.
				if (mIsOverridingDataspaceUnit)
					convertUnit(lValue, mValue);
				else
					mValue = lValue;
				
				// Filter repetitions.
				// This is done before clipping and integer truncation in order enforce views (returns) to stay within range when they attempt to set values out of range. See https://github.com/jamoma/JamomaMax/issues/934
				// Additionally: If ramps reach the end prematurely (due to requests for ramp targets beyond the accepted range), the ramp will not be stopped.
				
				if (mRepetitionsFilter)
                {
					if (mInitialized)
                    {
						TTValue tempValue = mValue;
						// Convert to integer if necsessary before comparing
						if (mType == kTTSym_integer)
							tempValue.truncate();
                        
						if (tempValue == lPreviousValue)
                        {
							// Unlock and exit without outputing
							mIsSending = NO;
							return kTTErrNone;
						}
					}
				}
				
				// Clipping
				clipValue();
				
				// Truncate if type is integer
				if (mType == kTTSym_integer)
					mValue.truncate();
				
				// Flag to ensure that value has been set at least once
				mInitialized = true;
			}
			returnValue();
			
			// unlock
			mIsSending = NO;
			
			return kTTErrNone;
		}
		else
        {
			// unlock
			mIsSending = NO;
			
			return kTTErrInvalidValue;
		}
	}
	
	return kTTErrGeneric;
}
예제 #6
0
TTErr TTData::IntegerDecimalArrayCommand(const TTValue& inputValue, TTValue& outputValue)
{
    TTDictionaryBasePtr command = NULL;
    TTSymbol		unit;
    TTUInt32        time;
    TTBoolean       isRunning;
    TTValue			c, v, aValue, none;
    
    if (inputValue.size())
    {
        // New command terminates any ongoing ramp
        if (mRamper.valid() && mRampStatus)
        {
            mRamper.send(kTTSym_Stop);
        }
        
        // Get the command TTDictionnary
        
        // This contains the new value and optional information on ramp and unit
        if (inputValue[0].type() == kTypePointer)
            command = TTDictionaryBasePtr((TTPtr)inputValue[0]);
        else
            return kTTErrGeneric;
        
        // Get the new target value. This might be specified in an overriding unit
        command->getValue(aValue);
        
        // For mType = "decimal" or "integer" it does not make sense to have more than one item in aValue.
        if ((mType == kTTSym_decimal) || (mType == kTTSym_integer))
        {
            if (aValue.size()>1)
                aValue.resize(1);
        }
        
        // Set up ramp if requested, this might include overriding dataspace unit
        if (mRamper.valid())
        {
            if (!command->lookup(kTTSym_ramp, v))
            {
                time = v[0];
                
                // Is a valid ramp time requested?
                if (time > 0) {
                    
                    TTValue rampStartValue;
                    
                    // Is the dataspace unit to be temporarily overridden during the ramp?
                    if ((mDataspaceConverter.valid()) && (!command->lookup(kTTSym_unit, v)))
                    {
                        unit = v[0];
                        
                        mIsOverridingDataspaceUnit = true;
                        
                        // Set up units for conversions
                        mDataspaceConverter.set(kTTSym_inputUnit, unit);
                        mDataspaceInverseConverter.set(kTTSym_outputUnit, unit);
                        
                        // Convert current value to temporary unit, and use as ramp start value
                        inverseConvertUnit(mValue, rampStartValue);
                    }
                    
                    // No dataspace unit conversion is needed during the ramp
                    else
                    {
                        mIsOverridingDataspaceUnit = false;
                        
                        rampStartValue = mValue;
                    }
                    
                    // Set the start ramp value
                    mRamper.send("Set", rampStartValue);
                    
                    // Set the end value using the overriding unit
                    mRamper.send("Target", aValue);
                    
                    // Set ramp time and start the ramp, we don't output any value immediately
                    mRamper.send(kTTSym_Go, (int)time);
                    
                    // Update the ramp status attribute
                    mRamper.get(kTTSym_running, isRunning);
                    if (mRampStatus != isRunning)
                    {
                        mRampStatus = isRunning;
                        notifyObservers(kTTSym_rampStatus, mRampStatus);
                    }
                    
                    return kTTErrNone;
                }
            }
        }
        // External ramp drive case - this is used with the j.parameter~ abstraction in Max. This is just a prototype until a proper C++ solution can be coded, and we do not bother to deal with ramp function or dataspace.
        else if (mRampDrive == kTTSym_external)
        {
            if (!command->lookup(kTTSym_ramp, v))
                externalRampTime = v[0];
        }
        
        // No ramping, target vale will be set immediately. This part of the method will only be executed if (a) no ramp was requested, (b) ramp time was less or equal to 0, or (c) we are using an external ramp drive.
        
        // Check for overriding unit, convert to default unit if necessary
        if ((mDataspaceConverter.valid()) && (!command->lookup(kTTSym_unit, v)))
        {
            TTValue convertedValue;
            
            unit = v[0];
            mDataspaceConverter.set(kTTSym_inputUnit, unit);
            convertUnit(aValue, convertedValue);
            aValue = convertedValue;
        }
        else
        {
            // Ramp and unit conversion implicitly ensure that type is kTypeFloat64, but if we don't have ramp or unit, we need to ensure that mValue is set as kTypeFloat64. We do not run this test if (aValue.size() == 0.). That will be the case in the Max implementation when sending a "bang" to j.parameter.
            // TODO: The following need to be reconsidered if this method is to cater for integers and arrays as well.
            if (mType == kTTSym_decimal)
            {
                if (aValue.size())
                {
                    if (aValue[0].type() != kTypeFloat64)
                        aValue = (TTFloat64)aValue[0];
                }
            }
            else if (mType == kTTSym_integer)
            {
                if (aValue.size())
                {
                    // Cast to int if
                    if (!checkIntegerType(aValue))
                        aValue = (TTInt32)aValue[0];
                    
                    aValue[0].truncate();
                }
            }
            else if (mType == kTTSym_array)
            {
                for (int i=0; i<aValue.size(); i++)
                    aValue[i] = (TTFloat64)aValue[i];
            }
        }
        
        mIsOverridingDataspaceUnit = false;
        
        // Update the ramp status attribute, unless we use external ramp drive
        if (mRamper.valid() && mRampDrive != kTTSym_external)
        {
            mRamper.get(kTTSym_running, isRunning);
            if (mRampStatus != isRunning)
            {
                mRampStatus = isRunning;
                notifyObservers(kTTSym_rampStatus, mRampStatus);
            }
        }
    }
    
    // Set the value directly
    return this->setIntegerDecimalArrayValue(aValue);
}
예제 #7
0
파일: tts_it.cpp 프로젝트: BenZoFly/opentx
I18N_PLAY_FUNCTION(it, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
/*  if digit >= 1000000000:
      temp_digit, digit = divmod(digit, 1000000000)
      prompts.extend(self.getNumberPrompt(temp_digit))
      prompts.append(Prompt(GUIDE_00_BILLION, dir=2))
  if digit >= 1000000:
      temp_digit, digit = divmod(digit, 1000000)
      prompts.extend(self.getNumberPrompt(temp_digit))
      prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
*/
  getvalue_t orignumber;
  if (number < 0) {
    PUSH_NUMBER_PROMPT(IT_PROMPT_MENO);
    number = -number;
  }
  orignumber=number;
#if !defined(CPUARM)
  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
    unit++;
  }
#endif

  int8_t mode = MODE(att);
  if (mode > 0) {
#if defined(CPUARM)
    if (mode == 2) {
      number /= 10;
    }
#else
    // we assume that we are PREC1
#endif
    div_t qr = div(number, 10);
    if (qr.rem > 0) {
      PLAY_NUMBER(qr.quot, 0, 0);
      PUSH_NUMBER_PROMPT(IT_PROMPT_VIRGOLA);
      if (mode==2 && qr.rem < 10)
        PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO);
      PLAY_NUMBER(qr.rem, 0, 0);
    }
    else {
      if (qr.quot==1) {
        PUSH_NUMBER_PROMPT(IT_PROMPT_UN);
        if (unit) {
          PUSH_NUMBER_PROMPT(IT_PROMPT_UNITS_BASE+(unit*2));
        }
        return;
      } else {
        PLAY_NUMBER(qr.quot, 0, 0);
      }
    }
  } else {
    if (orignumber == 1 && unit) {
      PUSH_NUMBER_PROMPT(IT_PROMPT_UN);
    } else {
      if (number >= 1000) {
        if (number >= 2000) {
          PLAY_NUMBER(number / 1000, 0, 0);
          PUSH_NUMBER_PROMPT(IT_PROMPT_MILA);
        } else {
          PUSH_NUMBER_PROMPT(IT_PROMPT_MILLE);
        }
        number %= 1000;
        if (number == 0)
          number = -1;
      }
      if (number >= 100) {
        if (number >= 200)
          PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO + number/100);
        PUSH_NUMBER_PROMPT(IT_PROMPT_CENT);
        number %= 100;
        if (number == 0)
          number = -1;
      }
      PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO+number);
    }
  }
  if (unit) {
    if (orignumber == 1) {
      PUSH_NUMBER_PROMPT(IT_PROMPT_UNITS_BASE+(unit*2));
    } else {
      PUSH_NUMBER_PROMPT(IT_PROMPT_UNITS_BASE+(unit*2)+1);
    }
  }
}
예제 #8
0
I18N_PLAY_FUNCTION(fr, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
/*  if digit >= 1000000000:
      temp_digit, digit = divmod(digit, 1000000000)
      prompts.extend(self.getNumberPrompt(temp_digit))
      prompts.append(Prompt(GUIDE_00_BILLION, dir=2))
  if digit >= 1000000:
      temp_digit, digit = divmod(digit, 1000000)
      prompts.extend(self.getNumberPrompt(temp_digit))
      prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
*/

  if (number < 0) {
    PUSH_NUMBER_PROMPT(FR_PROMPT_MOINS);
    number = -number;
  }

  int8_t mode = MODE(att);
  if (mode > 0) {
    // we assume that we are PREC1
    div_t qr = div(number, 10);
    if (qr.rem) {
      PLAY_NUMBER(qr.quot, 0, 0);
      PUSH_NUMBER_PROMPT(FR_PROMPT_VIRGULE_BASE + qr.rem);
      number = -1;
    }
    else {
      number = qr.quot;
    }
  }

  if (number >= 1000) {
    if (number >= 2000)
      PLAY_NUMBER(number / 1000, 0, 0);
    PUSH_NUMBER_PROMPT(FR_PROMPT_MILLE);
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    if (number >= 200)
      PUSH_NUMBER_PROMPT(FR_PROMPT_ZERO + number/100);
    PUSH_NUMBER_PROMPT(FR_PROMPT_CENT);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  if (((number % 10) == 1) && number < 90 && (att & FEMININ)) {
    PUSH_NUMBER_PROMPT(FR_PROMPT_UNE+(number/10));
  }
  else if (number >= 0) {
    PUSH_NUMBER_PROMPT(FR_PROMPT_ZERO+number);
  }

  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
    unit++;
    PUSH_NUMBER_PROMPT(FR_PROMPT_UNITS_BASE+unit);
  }
}
예제 #9
0
파일: tts_pt.cpp 프로젝트: 3drobotics/3drtx
I18N_PLAY_FUNCTION(pt, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
    if (number < 0) {
        PUSH_NUMBER_PROMPT(PT_PROMPT_MENOS);
        number = -number;
    }

    if (unit) {
        unit--;
        convertUnit(number, unit);
        if (IS_IMPERIAL_ENABLE()) {
            if (unit == UNIT_METERS) {
                unit = UNIT_FEET;
            }
        }
#if defined(CPUARM)
        if ((att & PREC1) && (unit == UNIT_FEET || (unit == UNIT_METERS && number >= 100))) {
            number /= 10;
            att -= PREC1;
        }
#endif
        unit++;
    }

    int8_t mode = MODE(att);
    if (mode > 0) {
        div_t qr = div(number, (mode == 1 ? 10 : 100));
        if (qr.rem > 0) {
            PLAY_NUMBER(qr.quot, 0, 0);
            PUSH_NUMBER_PROMPT(PT_PROMPT_VIRGULA);
            if (mode==2 && qr.rem < 10)
                PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO);
            PLAY_NUMBER(qr.rem, unit, 0);
        }
        else {
            PLAY_NUMBER(qr.quot, unit, 0);
        }
        return;
    }

    if (number >= 1000) {
        if (number >= 2000) {
            PLAY_NUMBER(number / 1000, 0, 0);
            PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
        } else {
            PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
        }
        number %= 1000;
        if (number == 0)
            number = -1;
    }
    if (number >= 100) {
        PUSH_NUMBER_PROMPT(PT_PROMPT_CENTO + number/100);
        number %= 100;
        if (number == 0)
            number = -1;
    }
    PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO+number);

    if (unit) {
        PUSH_NUMBER_PROMPT(PT_PROMPT_UNITS_BASE+unit-1);
    }
}
예제 #10
0
파일: tts_pl.cpp 프로젝트: DeBesten/opentx
I18N_PLAY_FUNCTION(pl, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{


#if defined(SIMU)
  printf("numer do powiedzenia2 %d ======== \n\n",number); 
  printf("UNIT2 %d ======== \n\n",unit); 
  printf("ATT %d ======== \n\n",att); 
#endif

  if (number < 0) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_MINUS);
    number = -number;
  }

  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_METERS) {
        unit = UNIT_FEET;
      }
    }
#if defined(CPUARM)
    if ((att & PREC1) && (unit == UNIT_FEET || (unit == UNIT_METERS && number >= 100))) {
      number /= 10;
      att -= PREC1;
    }
#endif
    unit++;
  }

  int8_t mode = MODE(att);
  if (mode > 0) {
    // we assume that we are PREC1
    div_t qr = div(number, 10);   
      if (qr.rem) {
        PLAY_NUMBER(qr.quot, 0, ZENSKI);
        if (qr.quot == 0)
          PUSH_NUMBER_PROMPT(PL_PROMPT_CALA);
        else
          PL_PUSH_UNIT_PROMPT(qr.quot, PL_PROMPT_CALA);
        PLAY_NUMBER(qr.rem, 0, ZENSKI);
        PUSH_NUMBER_PROMPT(PL_PROMPT_UNITS_BASE+((unit-1)*4)+3);
        return;
      }
      else
        number = qr.quot;
  }

  int16_t tmp = number;

  switch(unit) {
    case 0:
      att = MESKI;
      break;
    case 10:
    case 13:
    case 15:
    case 16:
    case 17:
      att = ZENSKI;
      break;
    case 100:
      att = NIJAKI;
      break;
    default:
      att = MESKI;
      break;
  }


  if ((number == 1) && (att == ZENSKI)) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_JEDNA);
    number = -1;
  }
  
  if ((number == 1) && (att == NIJAKI)) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_JEDNO);
    number = -1;
  }
  
  if ((number == 2) && (att == ZENSKI)) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_DWIE);
    number = -1;
  }
  




  if (number >= 1000) {
    if (number >= 2000) 
      PLAY_NUMBER(number / 1000, 0, 0);
    if (number >= 2000 && number < 5000)
      PUSH_NUMBER_PROMPT(PL_PROMPT_TISIACE);
    else
      PUSH_NUMBER_PROMPT(PL_PROMPT_TISIAC);
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    PUSH_NUMBER_PROMPT(PL_PROMPT_STO + (number/100)-1);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  
  if (number >= 0) {
    int test_2 =0;
    test_2 =number % 10;
    int dziesiatka=0;
    dziesiatka=(number - (number % 10))/10;
#if defined(SIMU)
    printf("dziesiatki %d - %d ==== ",dziesiatka,test_2);
#endif
    if (att == ZENSKI && test_2==2 && dziesiatka >= 2 ) {
      
      PUSH_NUMBER_PROMPT(PL_PROMPT_DZIESIATKI_ZENSKIE+dziesiatka);
    }else 
       PUSH_NUMBER_PROMPT(PL_PROMPT_ZERO+number);
  }

  if (unit) {
    PL_PUSH_UNIT_PROMPT(tmp, (PL_PROMPT_UNITS_BASE+((unit-1)*4)));
  }
}
예제 #11
0
I18N_PLAY_FUNCTION(it, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
/*  if digit >= 1000000000:
      temp_digit, digit = divmod(digit, 1000000000)
      prompts.extend(self.getNumberPrompt(temp_digit))
      prompts.append(Prompt(GUIDE_00_BILLION, dir=2))
  if digit >= 1000000:
      temp_digit, digit = divmod(digit, 1000000)
      prompts.extend(self.getNumberPrompt(temp_digit))
      prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
*/

  if (number < 0) {
    PUSH_NUMBER_PROMPT(IT_PROMPT_MENO);
    number = -number;
  }

  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
#if defined(CPUARM)
    if ((att & PREC1) && (unit == UNIT_FEET || (unit == UNIT_DIST && number >= 100))) {
      number = div10_and_round(number);
      att -= PREC1;
    }
#endif
    unit++;
  }

  int8_t mode = MODE(att);
  if (mode > 0) {
    div_t qr = div(number, (mode == 1 ? 10 : 100));
    if (qr.rem > 0) {
      PLAY_NUMBER(qr.quot, 0, 0);
      PUSH_NUMBER_PROMPT(IT_PROMPT_VIRGOLA);
      if (mode==2 && qr.rem < 10)
        PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO);
      PLAY_NUMBER(qr.rem, unit, 0);
    }
    else {
      PLAY_NUMBER(qr.quot, unit, 0);
    }
    return;
  }

  if (number >= 1000) {
    if (number >= 2000) {
      PLAY_NUMBER(number / 1000, 0, 0);
      PUSH_NUMBER_PROMPT(IT_PROMPT_MILA);
    } else {
      PUSH_NUMBER_PROMPT(IT_PROMPT_MILLE);
    }
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    if (number >= 200)
      PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO + number/100);
    PUSH_NUMBER_PROMPT(IT_PROMPT_CENT);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO+number);

  if (unit) {
    PUSH_NUMBER_PROMPT(IT_PROMPT_UNITS_BASE+unit-1);
  }
}
예제 #12
0
I18N_PLAY_FUNCTION(pt, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
  if (number < 0) {
    PUSH_NUMBER_PROMPT(PT_PROMPT_MENOS);
    number = -number;
  }

#if !defined(CPUARM)
  if (unit) {
    unit--;
    convertUnit(number, unit);
    if (IS_IMPERIAL_ENABLE()) {
      if (unit == UNIT_DIST) {
        unit = UNIT_FEET;
      }
      if (unit == UNIT_SPEED) {
    	unit = UNIT_KTS;
      }
    }
    unit++;
  }
#endif

  int8_t mode = MODE(att);
  if (mode > 0) {
#if defined(CPUARM)
    if (mode == 2) {
      number /= 10;
    }
#else
    // we assume that we are PREC1
#endif
    div_t qr = div(number, 10);
    if (qr.rem > 0) {
      PLAY_NUMBER(qr.quot, 0, 0);
      PUSH_NUMBER_PROMPT(PT_PROMPT_VIRGULA);
      if (mode==2 && qr.rem < 10)
        PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO);
      PLAY_NUMBER(qr.rem, unit, 0);
    }
    else {
      PLAY_NUMBER(qr.quot, unit, 0);
    }
    return;
  }

  if (number >= 1000) {
    if (number >= 2000) {
      PLAY_NUMBER(number / 1000, 0, 0);
      PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
    } else {
      PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
    }
    number %= 1000;
    if (number == 0)
      number = -1;
  }
  if (number >= 100) {
    PUSH_NUMBER_PROMPT(PT_PROMPT_CENTO + number/100);
    number %= 100;
    if (number == 0)
      number = -1;
  }
  PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO+number);

  if (unit) {
    PUSH_NUMBER_PROMPT(PT_PROMPT_UNITS_BASE+unit-1);
  }
}